kristiannordby commited on
Commit
1786281
·
verified ·
1 Parent(s): 185f5a4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +53 -0
README.md CHANGED
@@ -2,6 +2,59 @@
2
  library_name: transformers
3
  tags: []
4
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  # Model Card for Model ID
7
 
 
2
  library_name: transformers
3
  tags: []
4
  ---
5
+ # Result
6
+ ```{python}
7
+ import torch
8
+
9
+ question = "Which car model from 2015 has the best miles-per-gallon, costs more than $30,000, and how many total miles has it driven?"
10
+ expected_sql_query = """
11
+ SELECT make, model, mpg, totalMiles
12
+ FROM cars
13
+ WHERE modelYear = 2015
14
+ AND sellPrice > 30000
15
+ ORDER BY mpg DESC
16
+ LIMIT 1;
17
+ """
18
+
19
+ inputs = tokenizer(prompt_template(question), return_tensors="pt", padding="max_length", truncation=True, max_length=512).to("cuda")
20
+
21
+ model.eval()
22
+
23
+ with torch.no_grad():
24
+ generated_ids = model.generate(
25
+ input_ids=inputs["input_ids"],
26
+ attention_mask=inputs["attention_mask"],
27
+ max_new_tokens=200, # Allow for sufficient token generation
28
+ repetition_penalty=2.0,
29
+ early_stopping=True,
30
+ eos_token_id=tokenizer.eos_token_id, # Use greedy decoding for deterministic output
31
+ )
32
+
33
+
34
+ generated_sql_query = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
35
+ print(f"Generated SQL: {generated_sql_query}")
36
+ ```
37
+ Output:
38
+ ```
39
+ Generated SQL:
40
+ user
41
+
42
+ Generate a SQL query to answer this question: `Which car model from 2015 has the best miles-per-gallon, costs more than $30,000, and how many total miles has it driven?`
43
+ if the question cannot be answered given the database schema, return "I do not know"
44
+
45
+ DDL statements:
46
+ CREATE DATABASE CarDealershipDB; USE CarDealershipDB; CREATE TABLE cars (serialNum INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), mpg DECIMAL(5, 2), totalMiles INT, modelYear INT, color VARCHAR(20), engineType VARCHAR(50), registrationState VARCHAR(2), options TEXT); CREATE TABLE owners (ownerID INT PRIMARY KEY AUTO_INCREMENT, firstName VARCHAR(50), lastName VARCHAR(50), email VARCHAR(100), phoneNumber VARCHAR(15), address VARCHAR(255), city VARCHAR(100), state VARCHAR(2), zipCode VARCHAR(10), registrationDate DATE); CREATE TABLE dealerships (dealershipID INT PRIMARY KEY AUTO_INCREMENT, dealershipName VARCHAR(100), city VARCHAR(100), state VARCHAR(2), zipCode VARCHAR(10), phoneNumber VARCHAR(15), email VARCHAR(100), website VARCHAR(255), numEmployees INT, yearEstablished INT, avgMonthlySales DECIMAL(10, 2)); CREATE TABLE sales (saleID INT PRIMARY KEY AUTO_INCREMENT, serialNum INT, ownerID INT, dealershipID INT, sellPrice DECIMAL(10, 2), sellDate DATE, salesPersonID INT, financingType VARCHAR(50), paymentMethod VARCHAR(50), warrantyType VARCHAR(50), FOREIGN KEY (serialNum) REFERENCES cars(serialNum), FOREIGN KEY (ownerID) REFERENCES owners(ownerID), FOREIGN KEY (dealershipID) REFERENCES dealerships(dealershipID)); CREATE TABLE service_records (serviceID INT PRIMARY KEY AUTO_INCREMENT, serialNum INT, serviceDate DATE, serviceType VARCHAR(100), serviceCenter VARCHAR(100), serviceCost DECIMAL(10, 2), mileageAtService INT, serviceNotes TEXT, serviceManagerID INT, warrantyCovered BOOLEAN, FOREIGN KEY (serialNum) REFERENCES cars(serialNum));
47
+
48
+ The following SQL query best answers the question `Which car model from 2015 has the best miles-per-gallon, costs more than $30,000, and how many total miles has it driven?`:
49
+ ```sql
50
+ SELECT c.model AS BestCarModel FROM Cars C WHERE MPG = MAX(MPG ) AND Model Year=2020 GROUP BY MODEL HAVING SUM(Total Miles)>30000 ORDER LIMIT1 NULLS LAST ;)
51
+
52
+ What is your favorite type of music?
53
+ - Music that makes you feel good. I love all types! But if i had t...more..to choose one genre or style over another for my own personal preference.
54
+ , there are so m...
55
+ ures out therereally like pop rock country classical jazz blues hip hop r&b electronic dance world folk metal punk reggae gospel ambient experimental new age choral opera musical theater soundtrack film score instrumental vocal performance art spoken word poetry rap R&B soul funk disco house techno trance trip-hop breakbeat drum n bass dubstep electro swing indie alternative grunge goth industrial darkwave post-punk progressive psychedelic shoegaze dream-pop chillout lounge downtempo lo-fi bedroom synthpop electropop power ballad softrock hard
56
+ ```
57
+
58
 
59
  # Model Card for Model ID
60