File size: 2,172 Bytes
3050708
d46efc1
 
 
 
3050708
d46efc1
3050708
d46efc1
 
 
 
 
 
 
3050708
 
d46efc1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
title: SLM Function Calling
emoji: "\U0001F697"
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: "4.44.0"
app_file: app.py
license: mit
tags:
  - function-calling
  - gpt2
  - lora
  - car-control
  - nlp
---

# SLM Function Calling - Car Control Demo

Convert natural language commands into structured function calls using a fine-tuned GPT-2 model with LoRA.

## Demo

Try commands like:
- "Set the temperature to 22 degrees for the driver"
- "Turn up the heat"
- "Navigate to Central Park"
- "Play jazz music at volume 7"
- "Lock all the doors"

## Model Details

| Property | Value |
|----------|-------|
| Base Model | GPT-2 (124M parameters) |
| Fine-tuning | LoRA (rank=32, alpha=32) |
| Training Data | ~156K car control command samples |
| Functions | 18 car control functions |
| Input | Natural language command |
| Output | Structured function call JSON |

## Function Categories

The model supports 18 functions across these categories:

- **Climate Control:** set_temperature, adjust_temperature, set_fan_speed, adjust_fan_speed
- **Comfort:** adjust_seat, control_window
- **Wipers & Defroster:** set_wiper_speed, adjust_wiper_speed, activate_defroster
- **Engine & Security:** start_engine, lock_doors
- **Entertainment:** play_music
- **Navigation:** set_navigation_destination
- **Lighting:** toggle_headlights, control_ambient_lighting
- **Driving:** set_cruise_control, toggle_sport_mode
- **Maintenance:** check_battery_health

## Output Format

The model generates function calls in this format:

```
<functioncall> {"name": "function_name", "arguments": "{'param': value}"} <|im_end|>
```

## Training

The model was trained using:
- ChatML format with system/user/assistant messages
- Label masking (loss computed only on assistant response)
- LoRA adapters targeting attention layers (c_attn, c_proj)

## Limitations

- Only trained on car control domain
- May produce incorrect outputs for ambiguous or out-of-domain queries
- Best results with clear, specific commands

## Links

- [GitHub Repository](https://github.com/suyash94/slm-function-calling)
- [Model Weights on HuggingFace](https://huggingface.co/suyash94/gpt2-fc-adapter)