File size: 1,872 Bytes
982a907
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---

license: cc-by-4.0
language:
- en
tags:
- unity
- unity3d
- game-development
- csharp
- xr
- vr
- ar
- openxr
- code
- finetuned
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
datasets:
- vishnuOI/unity-dev-instructions
---


# Unity Coder 7B

A fine-tuned version of [Qwen2.5-Coder-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct)
specialized for Unity game development in C#.

## Training

- **Base model**: Qwen/Qwen2.5-Coder-7B-Instruct
- **Method**: QLoRA (4-bit NF4, r=16, alpha=32)
- **Dataset**: [vishnuOI/unity-dev-instructions](https://huggingface.co/datasets/vishnuOI/unity-dev-instructions)
- **Training pairs**: 1,687 Unity C# instruction pairs
- **Epochs**: 3

## Capabilities

- Unity C# scripting (MonoBehaviour, ScriptableObjects, coroutines)
- XR/VR development (OpenXR, XR Interaction Toolkit)
- Physics, animation, UI Toolkit
- Editor scripting and tooling
- Performance optimization patterns

## Usage

```python

from transformers import AutoTokenizer, AutoModelForCausalLM

import torch



model_id = "vishnuOI/unity-coder-7b"

tokenizer = AutoTokenizer.from_pretrained(model_id)

model = AutoModelForCausalLM.from_pretrained(

    model_id,

    torch_dtype=torch.bfloat16,

    device_map="auto",

)



messages = [

    {"role": "system", "content": "You are an expert Unity game developer specializing in C# scripting and XR development."},

    {"role": "user", "content": "How do I detect collision between two objects in Unity?"},

]



text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)

inputs = tokenizer(text, return_tensors="pt").to(model.device)



with torch.no_grad():

    outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.7, do_sample=True)



print(tokenizer.decode(outputs[0], skip_special_tokens=True))

```