Views
No views yet
SmolLM2-135M-Instructmicrosoft/orca-agentinstruct-1M-v1 — agentic tasks, RAG answers, classificationmicrosoft/orca-math-word-problems-200k — lightweight reasoningallenai/tulu-3-sft-personas-instruction-following — instruction followingxingyaoww/code-act — ReAct style reasoning and actionm-a-p/Code-Feedback — alignment via feedbackHuggingFaceTB/smoltalk + /apigen — tool calling stabilizationweijie210/gsm8k_decomposed — question decompositionLocutusque/function-calling-chatml — tool call response structure1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "quwsarohi/NanoAgent-135M"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForCausalLM.from_pretrained(model_name)
6
7def inference(messages, max_new_tokens=256, temperature=0.3, min_p=0.15, **kwargs):
8 input_text = tokenizer.apply_chat_template(
9 messages, tokenize=False, add_generation_prompt=True
10 )
11 inputs = tokenizer.encode(input_text, return_tensors="pt")
12 outputs = model.generate(
13 inputs,
14 max_new_tokens=max_new_tokens,
15 do_sample=True,
16 min_p=0.15,
17 temperature=temperature,
18 **kwargs
19 )
20 return tokenizer.decode(outputs[0][inputs.shape[1] :], skip_special_tokens=True)
21
22messages = [{"role": "user", "content": "Hi! Do you have a name?"}]
23print(inference(messages))1TOOL_TEMPLATE = """You are a helpful AI assistant. You have a set of possible functions/tools inside <tools></tools> tags.
2Based on question, you may need to make one or more function/tool calls to answer user.
3
4You have access to the following tools/functions:
5<tools>{tools}</tools>
6
7For each function call, return a JSON list object with function name and arguments within <tool_call></tool_call> tags."""1{
2 "name": "web_search",
3 "description": "Performs a web search for a query and returns a string of the top search results formatted as markdown with titles, links, and descriptions.",
4 "parameters": {
5 "type": "object",
6 "properties": {
7 "query": {
8 "type": "string",
9 "description": "The search query to perform.",
10 }
11 },
12 "required": ["query"],
13 },
14}