Views
No views yet
1from unsloth import FastLanguageModel
2
3max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
4dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
5load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
6
7model, tokenizer = FastLanguageModel.from_pretrained(
8 model_name = "outputs/checkpoint-3000", # YOUR MODEL YOU USED FOR TRAINING
9 max_seq_length = 1024,
10 dtype = dtype,
11 load_in_4bit = load_in_4bit,
12)
13FastLanguageModel.for_inference(model) # Enable native 2x faster inference
14
15tools = [
16 {
17 "name": "upcoming",
18 "description": "Fetches upcoming CS:GO matches data from the specified API endpoint.",
19 "parameters": {
20 "content_type": {
21 "description": "The content type for the request, default is 'application/json'.",
22 "type": "str",
23 "default": "application/json",
24 },
25 "page": {
26 "description": "The page number to retrieve, default is 1.",
27 "type": "int",
28 "default": "1",
29 },
30 "limit": {
31 "description": "The number of matches to retrieve per page, default is 10.",
32 "type": "int",
33 "default": "10",
34 },
35 },
36 }
37]
38messages = [
39 {
40 "role": "user",
41 "content": f"You are a helpful assistant. Below are the tools that you have access to. \n\n### Tools: \n{tools} \n\n### Query: \n{query} \n",
42 },
43]
44
45input = tokenizer.apply_chat_template(
46 messages, tokenize=True, add_generation_prompt=True, return_tensors="pt"
47)
48
49output = model.generate(
50 input_ids=input, max_new_tokens=512, temperature=0.0
51)
52
53decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)