Update README.md
Browse files
README.md
CHANGED
@@ -66,24 +66,15 @@ CUDA_VISIBLE_DEVICES=0,1 python eval.py \
|
|
66 |
## Usage
|
67 |
|
68 |
```python
|
69 |
-
from
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
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
|