id4thomas commited on
Commit
3664f11
·
1 Parent(s): 3e8404e

[add] initial commit

Browse files
README.md CHANGED
@@ -5,4 +5,74 @@ language:
5
  - en
6
  base_model:
7
  - Qwen/Qwen2.5-3B-Instruct
8
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  - en
6
  base_model:
7
  - Qwen/Qwen2.5-3B-Instruct
8
+ ---
9
+ # emotion-predictor-Qwen2.5-3B-Instruct
10
+ LLM trained to predict a character's emotional response in the given situation
11
+ * Trained to predict in a structured output format.
12
+
13
+ ## Quickstart
14
+ The model is trained to predict in the following schema
15
+ ```
16
+ from enum import Enum
17
+ from pydantic import BaseModel
18
+
19
+ class RelationshipStatus(str, Enum):
20
+ na = "na"
21
+ low = "low"
22
+ medium = "medium"
23
+ high = "high"
24
+
25
+ class EmotionLabel(BaseModel):
26
+ joy: RelationshipStatus
27
+ trust: RelationshipStatus
28
+ fear: RelationshipStatus
29
+ surprise: RelationshipStatus
30
+ sadness: RelationshipStatus
31
+ disgust: RelationshipStatus
32
+ anger: RelationshipStatus
33
+ anticipation: RelationshipStatus
34
+
35
+ class EntryResult(BaseModel):
36
+ emotion: EmotionLabel
37
+ reason: str
38
+ ```
39
+
40
+ Using `outlines` package to generate structured predictions
41
+ * system prompt & user template is provided [here](./assets/inference_prompt.yaml)
42
+ ```
43
+ import outlines
44
+ from outlines import models
45
+ from transformers import AutoTokenizer, AutoModelForCausalLM
46
+
47
+ model = AutoModelForCausalLM.from_pretrained("id4thomas/emotion-predictor-Qwen2.5-3B-Instruct")
48
+ tokenizer = AutoTokenizer.from_pretrained("id4thomas/emotion-predictor-Qwen2.5-3B-Instruct")
49
+
50
+ # Initalize outlines generator
51
+ outlines_model = models.Transformers(model, tokenizer)
52
+ generator = outlines.generate.json(outlines_model, EntryResult)
53
+
54
+ # Generate
55
+ messages = [
56
+ {"role": "system", "content": system_message},
57
+ {"role": "user", "content": user_message}
58
+ ]
59
+ input_text = tokenizer.apply_chat_template(
60
+ messages,
61
+ tokenize=False,
62
+ add_generation_prompt=True,
63
+ )
64
+ prediction = generator(input_text)
65
+ >>> EntryResult(emotion=EmotionLabel(joy=<RelationshipStatus.na: 'na'>, ...)
66
+ ```
67
+
68
+ Using endpoint loaded with vllm & OpenAI client package
69
+ ```
70
+ client = OpenAI(...)
71
+ json_schema = EntryResult.model_json_schema()
72
+ completion = client.chat.completions.create(
73
+ model="id4thomas/emotion-predictor-Qwen2.5-3B-Instruct",
74
+ messages=messages,
75
+ extra_body={"guided_json": json_schema},
76
+ )
77
+ print(completion.choices[0].message.content)
78
+ ```
adapter_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70bd2bf76ea9b5d7cc05e452ae66fc02c46ea27d9a181581ab6eef41317e6c5d
3
+ size 727
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:686639a3dcac44ca4f53e0625637483a2fcc8455ee6157afb35f93c7e4e3e028
3
+ size 59934640
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:58b54bbe36fc752f79a24a271ef66a0a0830054b4dfad94bde757d851968060b
3
+ size 605
assets/inference_prompt.yaml ADDED
File without changes
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
special_tokens_map.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a36726f7fe394c1324021cac4a9ee3ad6c4f6285c0d98721f9b0b95888ec9905
3
+ size 496
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83396048d512ec1f3178af0d7c1f79a226bba041822614b0e26a4fd2d4b55bf7
3
+ size 11421995
tokenizer_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f91b80bdb7722bdd0a25d79246fa79e513a7d4d78056b2eac8cbf92767937ab8
3
+ size 7333
train_configs.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6227fd5f3b6da1857d970d119a92df77f3d47d37032d469ef04e7a914d2e0686
3
+ size 1599
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:22564699907642dec439e91ce93396d3cbe68eef9f13b572f82ad2a5d49326f6
3
+ size 5496
vocab.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca10d7e9fb3ed18575dd1e277a2579c16d108e32f27439684afa0e10b1440910
3
+ size 2776833