anocha-mcomp commited on
Commit
150a1ca
·
verified ·
1 Parent(s): 0a61c89

Update model card from Confluence: Model Card: Gemma-SEA-LION-v4-4B-VL

Browse files
model_card_gemma-sea-lion-v4-4b-vl.md CHANGED
@@ -82,6 +82,80 @@ print(output[0]["generated_text"][-1]["content"])
82
  # Based on the image, the animal on the candy is a **turtle**.
83
  # You can see the shell shape and the head and legs.
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  ```
86
  ## Training Details
87
 
 
82
  # Based on the image, the animal on the candy is a **turtle**.
83
  # You can see the shell shape and the head and legs.
84
 
85
+ ```
86
+ ### Tool Calling
87
+
88
+ The prompt in the example is in Malay and translates to “Please help me find a 4-room flat near Tampines, budget under $500,000. I also want to know the estimated monthly loan payment.”
89
+
90
+ ```
91
+ import torch
92
+ from transformers import AutoTokenizer, AutoModelForCausalLM
93
+
94
+ tokenizer = AutoTokenizer.from_pretrained('aisingapore/gemma-sealion-4b-v4-cand5', trust_remote_code=True)
95
+ model = AutoModelForCausalLM.from_pretrained(
96
+ "aisingapore/gemma-sealion-4b-v4-cand5",
97
+ torch_dtype=torch.bfloat16,
98
+ device_map="auto"
99
+ )
100
+
101
+ messages = [
102
+ {"role": "user", "content": "Tolong carikan flat 4-bilik dekat Tampines, bajet bawah $500,000. Nak tahu juga berapa anggaran pinjaman bulanan."}
103
+ ]
104
+
105
+ tools = [
106
+ {
107
+ "type": "function",
108
+ "function": {
109
+ "name": "search_hdb_listings",
110
+ "description": "Search for HDB flats available for sale",
111
+ "parameters": {
112
+ "type": "object",
113
+ "properties": {
114
+ "location": {"type": "string", "description": "Town or area name"},
115
+ "flat_type": {"type": "string", "description": "Flat type e.g. 3-room, 4-room, 5-room"},
116
+ "max_price": {"type": "number", "description": "Maximum price in SGD"}
117
+ },
118
+ "required": ["location", "flat_type"]
119
+ }
120
+ }
121
+ },
122
+ {
123
+ "type": "function",
124
+ "function": {
125
+ "name": "calculate_mortgage",
126
+ "description": "Calculate estimated monthly mortgage payment",
127
+ "parameters": {
128
+ "type": "object",
129
+ "properties": {
130
+ "loan_amount": {"type": "number", "description": "Loan amount in SGD"},
131
+ "interest_rate": {"type": "number", "description": "Annual interest rate as percentage"},
132
+ "loan_tenure_years": {"type": "integer", "description": "Loan period in years"}
133
+ },
134
+ "required": ["loan_amount"]
135
+ }
136
+ }
137
+ }
138
+ ]
139
+
140
+ input_ids = tokenizer.apply_chat_template(
141
+ messages,
142
+ tools=tools,
143
+ return_tensors="pt",
144
+ add_generation_prompt=True
145
+ ).to(model.device)
146
+
147
+ generated_ids = model.generate(
148
+ input_ids,
149
+ max_new_tokens=512,
150
+ do_sample=False,
151
+ )
152
+
153
+ response = tokenizer.decode(
154
+ generated_ids[0][input_ids.shape[1]:],
155
+ skip_special_tokens=False,
156
+ ).replace("", "").strip()
157
+
158
+ print(response)
159
  ```
160
  ## Training Details
161