anocha-mcomp commited on
Commit
1254ebb
·
verified ·
1 Parent(s): 2ead25d

Update model card from Confluence: Model Card: Apertus-SEA-LION-v4-8B-IT

Browse files
model_card_apertus-sea-lion-v4-8b-it.md CHANGED
@@ -90,6 +90,80 @@ generated_ids = model.generate(**model_inputs, max_new_tokens=32768)
90
  output_ids = generated_ids[0][len(model_inputs.input_ids[0]) :]
91
  print(tokenizer.decode(output_ids, skip_special_tokens=True))
92
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  ## Training Details
94
 
95
  ### Training Data
 
90
  output_ids = generated_ids[0][len(model_inputs.input_ids[0]) :]
91
  print(tokenizer.decode(output_ids, skip_special_tokens=True))
92
  ```
93
+ ### Tool Calling
94
+
95
+ 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.”
96
+
97
+ ```
98
+ import torch
99
+ from transformers import AutoTokenizer, AutoModelForCausalLM
100
+
101
+ tokenizer = AutoTokenizer.from_pretrained('aisingapore/gemma-sealion-4b-v4-cand5', trust_remote_code=True)
102
+ model = AutoModelForCausalLM.from_pretrained(
103
+ "aisingapore/gemma-sealion-4b-v4-cand5",
104
+ torch_dtype=torch.bfloat16,
105
+ device_map="auto"
106
+ )
107
+
108
+ messages = [
109
+ {"role": "user", "content": "Tolong carikan flat 4-bilik dekat Tampines, bajet bawah $500,000. Nak tahu juga berapa anggaran pinjaman bulanan."}
110
+ ]
111
+
112
+ tools = [
113
+ {
114
+ "type": "function",
115
+ "function": {
116
+ "name": "search_hdb_listings",
117
+ "description": "Search for HDB flats available for sale",
118
+ "parameters": {
119
+ "type": "object",
120
+ "properties": {
121
+ "location": {"type": "string", "description": "Town or area name"},
122
+ "flat_type": {"type": "string", "description": "Flat type e.g. 3-room, 4-room, 5-room"},
123
+ "max_price": {"type": "number", "description": "Maximum price in SGD"}
124
+ },
125
+ "required": ["location", "flat_type"]
126
+ }
127
+ }
128
+ },
129
+ {
130
+ "type": "function",
131
+ "function": {
132
+ "name": "calculate_mortgage",
133
+ "description": "Calculate estimated monthly mortgage payment",
134
+ "parameters": {
135
+ "type": "object",
136
+ "properties": {
137
+ "loan_amount": {"type": "number", "description": "Loan amount in SGD"},
138
+ "interest_rate": {"type": "number", "description": "Annual interest rate as percentage"},
139
+ "loan_tenure_years": {"type": "integer", "description": "Loan period in years"}
140
+ },
141
+ "required": ["loan_amount"]
142
+ }
143
+ }
144
+ }
145
+ ]
146
+
147
+ input_ids = tokenizer.apply_chat_template(
148
+ messages,
149
+ tools=tools,
150
+ return_tensors="pt",
151
+ add_generation_prompt=True
152
+ ).to(model.device)
153
+
154
+ generated_ids = model.generate(
155
+ input_ids,
156
+ max_new_tokens=512,
157
+ do_sample=False,
158
+ )
159
+
160
+ response = tokenizer.decode(
161
+ generated_ids[0][input_ids.shape[1]:],
162
+ skip_special_tokens=False,
163
+ ).replace("", "").strip()
164
+
165
+ print(response)
166
+ ```
167
  ## Training Details
168
 
169
  ### Training Data