Update README.md
Browse files
README.md
CHANGED
@@ -44,6 +44,24 @@ Github: https://github.com/SeanLee97/AnglE
|
|
44 |
|
45 |
## Usage
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
```python
|
48 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
49 |
from peft import PeftModel, PeftConfig
|
|
|
44 |
|
45 |
## Usage
|
46 |
|
47 |
+
1) use AnglE
|
48 |
+
|
49 |
+
```bash
|
50 |
+
python -m pip install -U angle-emb
|
51 |
+
```
|
52 |
+
|
53 |
+
```python
|
54 |
+
from angle_emb import AnglE
|
55 |
+
angle = AnglE.from_pretrained('NousResearch/Llama-2-7b-hf', pretrained_lora_path='SeanLee97/angle-llama-7b-nli-v2')
|
56 |
+
angle.set_prompt()
|
57 |
+
print('prompt:', angle.prompt)
|
58 |
+
vec = angle.encode({'text': 'hello world'}, to_numpy=True)
|
59 |
+
print(vec)
|
60 |
+
vecs = angle.encode([{'text': 'hello world1'}, {'text': 'hello world2'}], to_numpy=True)
|
61 |
+
print(vecs)
|
62 |
+
```
|
63 |
+
|
64 |
+
2) use transformers
|
65 |
```python
|
66 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
67 |
from peft import PeftModel, PeftConfig
|