r1ck commited on
Commit
c25e918
·
verified ·
1 Parent(s): f404246
Files changed (1) hide show
  1. README.md +43 -9
README.md CHANGED
@@ -7,6 +7,11 @@ tags:
7
  - trl
8
  - sft
9
  licence: license
 
 
 
 
 
10
  ---
11
 
12
  # Model Card for output
@@ -17,20 +22,49 @@ It has been trained using [TRL](https://github.com/huggingface/trl).
17
  ## Quick start
18
 
19
  ```python
20
- from transformers import pipeline
21
 
22
- question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
23
- generator = pipeline("text-generation", model="r1ck/output", device="cuda")
24
- output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
25
- print(output["generated_text"])
26
- ```
27
 
28
- ## Training procedure
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
-
 
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- This model was trained with SFT.
34
 
35
  ### Framework versions
36
 
 
7
  - trl
8
  - sft
9
  licence: license
10
+ license: apache-2.0
11
+ language:
12
+ - vi
13
+ - en
14
+ pipeline_tag: image-text-to-text
15
  ---
16
 
17
  # Model Card for output
 
22
  ## Quick start
23
 
24
  ```python
25
+ from transformers import AutoTokenizer, Gemma3ForConditionalGeneration
26
 
 
 
 
 
 
27
 
28
+ MODEL_PATH = "r1ck/gemma-3-4b-it-rw"
29
+
30
+ model = Gemma3ForConditionalGeneration.from_pretrained(
31
+ MODEL_PATH, device_map="auto", attn_implementation='eager'
32
+ ).eval()
33
+
34
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
35
+
36
+ prompt_template = """Given a conversation between (user, assistant) and a follow-up message from user, your task is to rewrite the follow-up message to a standalone message that captures all relevant context from the conversation.
37
+ Consume the entire conversation and follow-up message and think deeply about it. If the follow-up message is already clear, don't need to rewrite it, just return the original message. The rewritten message must be in Vietnamese.
38
+
39
+ # Conversation:
40
+ user: Hà Nội có những đặc điểm văn hóa nào nổi bật từ lịch sử?
41
+ assistant: Hà Nội, với lịch sử là kinh đô của Việt Nam, đã hội tụ nhiều tinh hoa văn hóa từ miền Bắc và cả nước. Thành phố này là nơi quy tụ của những nhân vật ưu tú, thương nhân, nghệ nhân, và thợ thủ công lành nghề từ khắp nơi. Họ mang theo phong tục, tập quán địa phương của mình, từ đó tạo nên nét văn hóa đặc trưng cho Hà Nội.
42
 
43
+ # Follow-up message:
44
+ Điều này mang lại lợi ích gì về du lịch?
45
 
46
+ # Rewritten message:
47
+ """
48
+
49
+ inputs = tokenizer(
50
+ [prompt_template],
51
+ return_tensors="pt"
52
+ ).to("cuda")
53
+
54
+ outputs = model.generate(
55
+ input_ids=inputs.input_ids,
56
+ attention_mask=inputs.attention_mask,
57
+ max_new_tokens=2048,
58
+ eos_token_id=tokenizer.eos_token_id,
59
+ use_cache=True,
60
+ )
61
+ response = tokenizer.batch_decode(outputs, skip_special_tokens=True)
62
+ print(response[0])
63
+ ```
64
+
65
+ ## Training procedure
66
 
67
+ This model was trained with SFT For: Query rewrite based on conversation history task
68
 
69
  ### Framework versions
70