Akil15 commited on
Commit
ad8b95a
1 Parent(s): c28f3cc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +36 -0
README.md CHANGED
@@ -24,6 +24,42 @@ train/epoch : 5.0
24
  train/global_step : 10
25
 
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  ### Framework versions
28
 
29
 
 
24
  train/global_step : 10
25
 
26
 
27
+ ## Inference Code
28
+
29
+ After doing necessary imports
30
+
31
+ device_map = {"": 0}
32
+ model_id = "mistralai/Mistral-7B-v0.1"
33
+ new_model = "Akil15/mistral_SQL_v.0.1"
34
+
35
+ # Reload model in FP16 and merge it with LoRA weights
36
+
37
+ base_model = AutoModelForCausalLM.from_pretrained(
38
+ model_id,
39
+ torch_dtype=torch.float16,
40
+ device_map=device_map,
41
+ )
42
+
43
+ model = PeftModel.from_pretrained(base_model, new_model)
44
+ model = model.merge_and_unload()
45
+
46
+ # Reload tokenizer to save it
47
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
48
+ tokenizer.pad_token = tokenizer.eos_token
49
+ tokenizer.padding_side = "right"
50
+
51
+ sample text(example):
52
+
53
+ text = """Question: How many vegetable farms with over 100 acres of cultivated land utilize organic farming methods, and what is the average yield per acre for these farms?
54
+ Context:CREATE TABLE vegetable_farm (Acres INTEGER,Organic BOOLEAN,Yield_Per_Acre DECIMAL);"""
55
+
56
+ text = input()
57
+ inputs = tokenizer(text, return_tensors="pt").to(device)
58
+ outputs = model.generate(**inputs, max_new_tokens=20)
59
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
60
+
61
+ Note: Change the max_new_tokens length based on the question-context text input or just define it to 100
62
+
63
  ### Framework versions
64
 
65