sarvkk commited on
Commit
d091a8b
·
verified ·
1 Parent(s): f41b5c4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +175 -176
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
- - transformers
 
 
 
 
 
 
9
  ---
10
 
11
- # Model Card for Model ID
12
-
13
- <!-- Provide a quick summary of what the model is/does. -->
14
-
15
-
16
-
17
- ## Model Details
18
-
19
- ### Model Description
20
-
21
- <!-- Provide a longer summary of what this model is. -->
22
-
23
-
24
-
25
- - **Developed by:** [More Information Needed]
26
- - **Funded by [optional]:** [More Information Needed]
27
- - **Shared by [optional]:** [More Information Needed]
28
- - **Model type:** [More Information Needed]
29
- - **Language(s) (NLP):** [More Information Needed]
30
- - **License:** [More Information Needed]
31
- - **Finetuned from model [optional]:** [More Information Needed]
32
-
33
- ### Model Sources [optional]
34
-
35
- <!-- Provide the basic links for the model. -->
36
-
37
- - **Repository:** [More Information Needed]
38
- - **Paper [optional]:** [More Information Needed]
39
- - **Demo [optional]:** [More Information Needed]
40
-
41
- ## Uses
42
-
43
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
44
-
45
- ### Direct Use
46
-
47
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
48
-
49
- [More Information Needed]
50
-
51
- ### Downstream Use [optional]
52
-
53
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
54
-
55
- [More Information Needed]
56
-
57
- ### Out-of-Scope Use
58
-
59
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
60
-
61
- [More Information Needed]
62
-
63
- ## Bias, Risks, and Limitations
64
-
65
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
66
-
67
- [More Information Needed]
68
-
69
- ### Recommendations
70
-
71
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
72
-
73
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
74
-
75
- ## How to Get Started with the Model
76
-
77
- Use the code below to get started with the model.
78
-
79
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  ## Training Details
82
 
83
  ### Training Data
84
 
85
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
86
-
87
- [More Information Needed]
88
-
89
- ### Training Procedure
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
- #### Training Hyperparameters
99
 
100
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
101
 
102
- #### Speeds, Sizes, Times [optional]
 
 
 
 
 
 
 
 
 
103
 
104
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
105
 
106
- [More Information Needed]
 
 
 
107
 
108
- ## Evaluation
109
 
110
- <!-- This section describes the evaluation protocols and provides the results. -->
 
 
 
111
 
112
- ### Testing Data, Factors & Metrics
113
 
114
- #### Testing Data
 
 
 
 
115
 
116
- <!-- This should link to a Dataset Card if possible. -->
 
 
 
 
117
 
118
- [More Information Needed]
119
 
120
- #### Factors
121
 
122
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
123
 
124
- [More Information Needed]
 
 
 
 
 
 
 
 
 
125
 
126
- #### Metrics
127
 
128
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
 
 
129
 
130
- [More Information Needed]
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
- - PEFT 0.18.1
 
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!