PEFT
English
SeanLee97 commited on
Commit
6bb8fbe
·
1 Parent(s): b325d86

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +8 -17
README.md CHANGED
@@ -66,24 +66,15 @@ CUDA_VISIBLE_DEVICES=0,1 python eval.py \
66
  ## Usage
67
 
68
  ```python
69
- from transformers import AutoModelForCausalLM, AutoTokenizer
70
- from peft import PeftModel, PeftConfig
71
-
72
- peft_model_id = 'SeanLee97/angle-llama-7b-nli-20231027'
73
- config = PeftConfig.from_pretrained(peft_model_id)
74
- tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
75
- model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path).bfloat16().cuda()
76
- model = PeftModel.from_pretrained(model, peft_model_id).cuda()
77
-
78
- def decorate_text(text: str):
79
- return f'Summarize sentence "{text}" in one word:"'
80
-
81
- inputs = 'hello world!'
82
- tok = tokenizer([decorate_text(inputs)], return_tensors='pt')
83
- for k, v in tok.items():
84
- tok[k] = v.cuda()
85
- vec = model(output_hidden_states=True, **tok).hidden_states[-1][:, -1].float().detach().cpu().numpy()
86
  print(vec)
 
 
87
  ```
88
 
89
  ## Citation
 
66
  ## Usage
67
 
68
  ```python
69
+ from angle_emb import AnglE
70
+
71
+ angle = AnglE.from_pretrained('NousResearch/Llama-2-7b-hf', pretrained_lora_path='SeanLee97/angle-llama-7b-nli-20231027')
72
+ angle.set_prompt()
73
+ print('prompt:', angle.prompt)
74
+ vec = angle.encode({'text': 'hello world'}, to_numpy=True)
 
 
 
 
 
 
 
 
 
 
 
75
  print(vec)
76
+ vecs = angle.encode([{'text': 'hello world1'}, {'text': 'hello world2'}], to_numpy=True)
77
+ print(vecs)
78
  ```
79
 
80
  ## Citation