Update README.md
Browse files
README.md
CHANGED
|
@@ -3,205 +3,204 @@ base_model: google/gemma-2-2b-it
|
|
| 3 |
library_name: peft
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
tags:
|
| 6 |
-
- base_model:adapter:google/gemma-2-2b-it
|
| 7 |
- lora
|
| 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 |
## Training Details
|
| 82 |
|
| 83 |
### Training Data
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 92 |
-
|
| 93 |
-
#### Preprocessing [optional]
|
| 94 |
-
|
| 95 |
-
[More Information Needed]
|
| 96 |
-
|
| 97 |
|
| 98 |
-
|
| 99 |
|
| 100 |
-
|
| 101 |
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
-
|
| 105 |
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
-
##
|
| 109 |
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
-
##
|
| 113 |
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
-
|
| 119 |
|
| 120 |
-
|
| 121 |
|
| 122 |
-
|
| 123 |
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
-
##
|
| 127 |
|
| 128 |
-
|
|
|
|
|
|
|
| 129 |
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
### Results
|
| 133 |
-
|
| 134 |
-
[More Information Needed]
|
| 135 |
-
|
| 136 |
-
#### Summary
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
## Model Examination [optional]
|
| 141 |
-
|
| 142 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 143 |
-
|
| 144 |
-
[More Information Needed]
|
| 145 |
-
|
| 146 |
-
## Environmental Impact
|
| 147 |
-
|
| 148 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 149 |
-
|
| 150 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 151 |
-
|
| 152 |
-
- **Hardware Type:** [More Information Needed]
|
| 153 |
-
- **Hours used:** [More Information Needed]
|
| 154 |
-
- **Cloud Provider:** [More Information Needed]
|
| 155 |
-
- **Compute Region:** [More Information Needed]
|
| 156 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 157 |
-
|
| 158 |
-
## Technical Specifications [optional]
|
| 159 |
-
|
| 160 |
-
### Model Architecture and Objective
|
| 161 |
-
|
| 162 |
-
[More Information Needed]
|
| 163 |
-
|
| 164 |
-
### Compute Infrastructure
|
| 165 |
-
|
| 166 |
-
[More Information Needed]
|
| 167 |
-
|
| 168 |
-
#### Hardware
|
| 169 |
-
|
| 170 |
-
[More Information Needed]
|
| 171 |
-
|
| 172 |
-
#### Software
|
| 173 |
-
|
| 174 |
-
[More Information Needed]
|
| 175 |
-
|
| 176 |
-
## Citation [optional]
|
| 177 |
-
|
| 178 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 179 |
-
|
| 180 |
-
**BibTeX:**
|
| 181 |
-
|
| 182 |
-
[More Information Needed]
|
| 183 |
-
|
| 184 |
-
**APA:**
|
| 185 |
-
|
| 186 |
-
[More Information Needed]
|
| 187 |
-
|
| 188 |
-
## Glossary [optional]
|
| 189 |
-
|
| 190 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 191 |
-
|
| 192 |
-
[More Information Needed]
|
| 193 |
-
|
| 194 |
-
## More Information [optional]
|
| 195 |
-
|
| 196 |
-
[More Information Needed]
|
| 197 |
-
|
| 198 |
-
## Model Card Authors [optional]
|
| 199 |
-
|
| 200 |
-
[More Information Needed]
|
| 201 |
-
|
| 202 |
-
## Model Card Contact
|
| 203 |
-
|
| 204 |
-
[More Information Needed]
|
| 205 |
-
### Framework versions
|
| 206 |
|
| 207 |
-
|
|
|
|
| 3 |
library_name: peft
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
tags:
|
|
|
|
| 6 |
- lora
|
| 7 |
+
- function-calling
|
| 8 |
+
- sports
|
| 9 |
+
- event-parsing
|
| 10 |
+
- natural-language-processing
|
| 11 |
+
license: gemma
|
| 12 |
+
language:
|
| 13 |
+
- en
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# Gemma 2B Event Parser - Sports Event Function Calling
|
| 17 |
+
|
| 18 |
+
A fine-tuned LoRA adapter for Gemma 2B that converts natural language descriptions into structured JSON for creating sports events.
|
| 19 |
+
|
| 20 |
+
## Model Description
|
| 21 |
+
|
| 22 |
+
This model takes casual text like **"I want to play soccer this week Friday 4 PM @ Central Park"** and converts it into a properly formatted `CreateEventRequest` JSON object for backend API consumption.
|
| 23 |
+
|
| 24 |
+
**Base Model:** `google/gemma-2-2b-it`
|
| 25 |
+
**Fine-tuning Method:** LoRA (Low-Rank Adaptation)
|
| 26 |
+
**Training Framework:** Transformers + PEFT
|
| 27 |
+
**Primary Use Case:** Natural language to structured API requests for sports event creation
|
| 28 |
+
|
| 29 |
+
## Usage
|
| 30 |
+
|
| 31 |
+
### Installation
|
| 32 |
+
```bash
|
| 33 |
+
pip install transformers peft torch
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
### Quick Start
|
| 37 |
+
```python
|
| 38 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 39 |
+
from peft import PeftModel
|
| 40 |
+
import torch
|
| 41 |
+
import json
|
| 42 |
+
|
| 43 |
+
# Load base model
|
| 44 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 45 |
+
"google/gemma-2-2b-it",
|
| 46 |
+
device_map="auto",
|
| 47 |
+
dtype=torch.float16
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
# Load fine-tuned adapter
|
| 51 |
+
model = PeftModel.from_pretrained(base_model, "YOUR_USERNAME/gemma-event-parser")
|
| 52 |
+
tokenizer = AutoTokenizer.from_pretrained("YOUR_USERNAME/gemma-event-parser")
|
| 53 |
+
|
| 54 |
+
# Define function schema
|
| 55 |
+
function_schema = {
|
| 56 |
+
"name": "create_sports_event",
|
| 57 |
+
"description": "Create a new sports event from natural language description",
|
| 58 |
+
"parameters": {
|
| 59 |
+
"type": "object",
|
| 60 |
+
"properties": {
|
| 61 |
+
"sport": {"type": "string", "description": "Sport type (e.g., Soccer, Basketball, Tennis)"},
|
| 62 |
+
"venue_name": {"type": "string", "description": "Venue name"},
|
| 63 |
+
"start_time": {"type": "string", "description": "ISO 8601 format (e.g., 2026-02-07T16:00:00Z)"},
|
| 64 |
+
"max_participants": {"type": "integer", "default": 2},
|
| 65 |
+
"event_type": {
|
| 66 |
+
"type": "string",
|
| 67 |
+
"enum": ["Casual", "Light Training", "Looking to Improve", "Competitive Game"],
|
| 68 |
+
"default": "Casual"
|
| 69 |
+
}
|
| 70 |
+
},
|
| 71 |
+
"required": ["sport", "venue_name", "start_time"]
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
# Parse natural language
|
| 76 |
+
def parse_event(user_query):
|
| 77 |
+
prompt = f"""<start_of_turn>user
|
| 78 |
+
{user_query}
|
| 79 |
+
|
| 80 |
+
Available functions:
|
| 81 |
+
{json.dumps([function_schema], indent=2)}<end_of_turn>
|
| 82 |
+
<start_of_turn>model
|
| 83 |
+
"""
|
| 84 |
+
|
| 85 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 86 |
+
outputs = model.generate(
|
| 87 |
+
**inputs,
|
| 88 |
+
max_new_tokens=256,
|
| 89 |
+
temperature=0.1,
|
| 90 |
+
do_sample=True,
|
| 91 |
+
top_p=0.95
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 95 |
+
|
| 96 |
+
# Extract JSON
|
| 97 |
+
start = result.find("<function_call>") + len("<function_call>")
|
| 98 |
+
end = result.find("</function_call>")
|
| 99 |
+
function_call = json.loads(result[start:end].strip())
|
| 100 |
+
|
| 101 |
+
return function_call["arguments"]
|
| 102 |
+
|
| 103 |
+
# Example
|
| 104 |
+
query = "I want to play soccer this week Friday 4 PM @ Central Park"
|
| 105 |
+
event_json = parse_event(query)
|
| 106 |
+
print(json.dumps(event_json, indent=2))
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
**Output:**
|
| 110 |
+
```json
|
| 111 |
+
{
|
| 112 |
+
"sport": "Soccer",
|
| 113 |
+
"venue_name": "Central Park",
|
| 114 |
+
"start_time": "2026-02-07T16:00:00Z",
|
| 115 |
+
"max_participants": 22,
|
| 116 |
+
"event_type": "Casual"
|
| 117 |
+
}
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
## Examples
|
| 121 |
+
|
| 122 |
+
| Input | Output |
|
| 123 |
+
|-------|--------|
|
| 124 |
+
| "Basketball game tomorrow 6pm at Riverside Courts, competitive" | `{"sport": "Basketball", "venue_name": "Riverside Courts", "start_time": "2026-02-07T18:00:00Z", "max_participants": 10, "event_type": "Competitive Game"}` |
|
| 125 |
+
| "Tennis match Wednesday 10 AM Ashburn Park, looking to improve" | `{"sport": "Tennis", "venue_name": "Ashburn Park", "start_time": "2026-02-12T10:00:00Z", "max_participants": 2, "event_type": "Looking to Improve"}` |
|
| 126 |
+
| "Casual volleyball Saturday 2pm Beach Courts" | `{"sport": "Volleyball", "venue_name": "Beach Courts", "start_time": "2026-02-08T14:00:00Z", "max_participants": 12, "event_type": "Casual"}` |
|
| 127 |
|
| 128 |
## Training Details
|
| 129 |
|
| 130 |
### Training Data
|
| 131 |
|
| 132 |
+
Fine-tuned on synthetic examples covering:
|
| 133 |
+
- Multiple sports (Soccer, Basketball, Tennis, Volleyball, Badminton, etc.)
|
| 134 |
+
- Various time formats (relative dates, specific times)
|
| 135 |
+
- All event types (Casual, Light Training, Looking to Improve, Competitive Game)
|
| 136 |
+
- Different venue patterns
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
+
**Training Size:** ~10-20 high-quality examples (LoRA requires less data)
|
| 139 |
|
| 140 |
+
### Training Hyperparameters
|
| 141 |
|
| 142 |
+
- **LoRA Rank (r):** 16
|
| 143 |
+
- **LoRA Alpha:** 32
|
| 144 |
+
- **Target Modules:** `q_proj, k_proj, v_proj, o_proj`
|
| 145 |
+
- **Learning Rate:** 2e-4
|
| 146 |
+
- **Epochs:** 20
|
| 147 |
+
- **Batch Size:** 2 (with gradient accumulation: 4)
|
| 148 |
+
- **Optimizer:** AdamW
|
| 149 |
+
- **Scheduler:** Cosine with warmup
|
| 150 |
+
- **Precision:** FP16
|
| 151 |
+
- **Training Time:** ~1-2 minutes on free Colab
|
| 152 |
|
| 153 |
+
### Framework Versions
|
| 154 |
|
| 155 |
+
- **Transformers:** 4.x
|
| 156 |
+
- **PEFT:** 0.18.1
|
| 157 |
+
- **PyTorch:** 2.x
|
| 158 |
+
- **Python:** 3.10+
|
| 159 |
|
| 160 |
+
## Limitations
|
| 161 |
|
| 162 |
+
- **Date Parsing:** Currently handles relative dates ("Friday", "tomorrow") but assumes current week context
|
| 163 |
+
- **Time Zones:** Defaults to UTC (Z suffix)
|
| 164 |
+
- **Sports Coverage:** Best performance on common sports; may need examples for niche sports
|
| 165 |
+
- **Language:** English only
|
| 166 |
|
| 167 |
+
## Intended Use
|
| 168 |
|
| 169 |
+
✅ **Good for:**
|
| 170 |
+
- Converting casual user input to structured API requests
|
| 171 |
+
- Sports event management applications
|
| 172 |
+
- Voice-to-API integrations
|
| 173 |
+
- Chatbot backends for sports booking
|
| 174 |
|
| 175 |
+
❌ **Not suitable for:**
|
| 176 |
+
- Mission-critical systems without validation
|
| 177 |
+
- Non-English languages
|
| 178 |
+
- Complex multi-event scheduling
|
| 179 |
+
- Historical date parsing
|
| 180 |
|
| 181 |
+
## License
|
| 182 |
|
| 183 |
+
This adapter follows the [Gemma License](https://ai.google.dev/gemma/terms). The base model is subject to Google's Gemma terms of use.
|
| 184 |
|
| 185 |
+
## Citation
|
| 186 |
|
| 187 |
+
If you use this model, please cite:
|
| 188 |
+
```bibtex
|
| 189 |
+
@misc{gemma-event-parser-2026,
|
| 190 |
+
author = {YOUR_NAME},
|
| 191 |
+
title = {Gemma 2B Event Parser - Sports Event Function Calling},
|
| 192 |
+
year = {2026},
|
| 193 |
+
publisher = {HuggingFace},
|
| 194 |
+
url = {https://huggingface.co/YOUR_USERNAME/gemma-event-parser}
|
| 195 |
+
}
|
| 196 |
+
```
|
| 197 |
|
| 198 |
+
## Acknowledgments
|
| 199 |
|
| 200 |
+
- Base model: Google's Gemma 2B-IT
|
| 201 |
+
- Fine-tuning framework: Hugging Face PEFT
|
| 202 |
+
- Training compute: Google Colab
|
| 203 |
|
| 204 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
+
**Questions?** Open an issue or discussion on this model's page!
|