File size: 855 Bytes
75391ba
 
 
 
2e58c42
 
42dd54d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
language:
- en
library_name: transformers
datasets:
- b-mc2/sql-create-context
---

Toy model finetuned on the `b-mc2/sql-create-context` dataset.

## Sample Code

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

model = AutoModelForCausalLM.from_pretrained("Artifact-io/toy-sql-28M").to(device)
tokenizer = AutoTokenizer.from_pretrained("Artifact-io/toy-sql-28M")

inputs = tokenizer([
"""CREATE TABLE head (age INTEGER)
How many heads of the departments are older than 56?
"""
  ],
  return_tensors="pt",
).to(device)

outputs = model.generate(**inputs, max_new_tokens=200, do_sample=True, top_k=50, top_p=0.95)
text = tokenizer.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0].split("---")[0]
print(text)
```