Update README.md
Browse files
README.md
CHANGED
@@ -18,78 +18,3 @@ Phi-1.5 has been integrated in the `transformers` version 4.37.0. If you are usi
|
|
18 |
|
19 |
The current `transformers` version can be verified with: `pip list | grep transformers`.
|
20 |
|
21 |
-
## Example
|
22 |
-
```python
|
23 |
-
import torch
|
24 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
25 |
-
|
26 |
-
torch.set_default_device("cuda")
|
27 |
-
|
28 |
-
model = AutoModelForCausalLM.from_pretrained("voidful/qd-phi-1_5",trust_remote_code=True)
|
29 |
-
tokenizer = AutoTokenizer.from_pretrained("voidful/qd-phi-1_5", trust_remote_code=True,device_map="auto")
|
30 |
-
|
31 |
-
from transformers import StoppingCriteria
|
32 |
-
class EosListStoppingCriteria(StoppingCriteria):
|
33 |
-
def __init__(self, eos_sequence = tokenizer.encode("[END]")):
|
34 |
-
self.eos_sequence = eos_sequence
|
35 |
-
|
36 |
-
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
|
37 |
-
last_ids = input_ids[:,-len(self.eos_sequence):].tolist()
|
38 |
-
return self.eos_sequence in last_ids
|
39 |
-
|
40 |
-
inputs = tokenizer("Is it better to love or to be loved?", return_tensors="pt", return_attention_mask=True)
|
41 |
-
|
42 |
-
outputs = model.generate(**inputs, max_length=1024, stopping_criteria = [EosListStoppingCriteria()])
|
43 |
-
text = tokenizer.batch_decode(outputs)[0]
|
44 |
-
print(text)
|
45 |
-
```
|
46 |
-
|
47 |
-
## Result
|
48 |
-
*Question* Is it better to love or to be loved?
|
49 |
-
*Decomposition*
|
50 |
-
```json
|
51 |
-
{
|
52 |
-
"What does it mean to love?": [
|
53 |
-
"How do different philosophical, psychological, and cultural perspectives define love?",
|
54 |
-
"What are the characteristics and types of love?",
|
55 |
-
"How does love affect human behavior and well-being?"
|
56 |
-
],
|
57 |
-
"What does it mean to be loved?": [
|
58 |
-
"How do different philosophical, psychological, and cultural perspectives define being loved?",
|
59 |
-
"What are the characteristics and types of being loved?",
|
60 |
-
"How does being loved affect human behavior and well-being?"
|
61 |
-
],
|
62 |
-
"What are the benefits and drawbacks of loving oneself?": [
|
63 |
-
"How does loving oneself relate to self-esteem, self-acceptance, and self-care?",
|
64 |
-
"How does loving oneself affect one's relationships with others?",
|
65 |
-
"What are the challenges and risks of loving oneself?"
|
66 |
-
],
|
67 |
-
"What are the benefits and drawbacks of being loved by others?": [
|
68 |
-
"How does being loved by others relate to social connection, belonging, and support?",
|
69 |
-
"How does being loved by others affect one's identity, autonomy, and agency?",
|
70 |
-
"What are the challenges and risks of being loved by others?"
|
71 |
-
],
|
72 |
-
"How do the concepts of loving and being loved interact and influence each other?": [
|
73 |
-
"How do different situations and contexts affect the dynamics of love and being loved?",
|
74 |
-
"How do different individuals and groups experience and express love and being loved differently?",
|
75 |
-
"How do love and being loved shape and change over time?"
|
76 |
-
],
|
77 |
-
"How can one balance and integrate love and being loved in one's life?": [
|
78 |
-
"What are some strategies and practices to cultivate and sustain love and being loved?",
|
79 |
-
"What are some examples and models of healthy and unhealthy relationships with love and being loved?",
|
80 |
-
"What are some goals and values that guide one's choices and actions regarding love and being loved?"
|
81 |
-
]
|
82 |
-
}
|
83 |
-
```
|
84 |
-
|
85 |
-
*Queries*
|
86 |
-
```
|
87 |
-
definition and types of love
|
88 |
-
definition and types of being loved
|
89 |
-
benefits and drawbacks of loving oneself
|
90 |
-
benefits and drawbacks of being loved by others
|
91 |
-
interaction and influence of love and being loved
|
92 |
-
strategies and practices to balance and integrate love and being loved
|
93 |
-
examples and models of healthy and unhealthy relationships with love and being loved
|
94 |
-
goals and values regarding love and being loved
|
95 |
-
```
|
|
|
18 |
|
19 |
The current `transformers` version can be verified with: `pip list | grep transformers`.
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|