ManthanKulakarni
commited on
Commit
•
eca62c7
1
Parent(s):
2551cec
add sample code to run the model
Browse files
README.md
CHANGED
@@ -10,4 +10,30 @@ tags:
|
|
10 |
- JQL
|
11 |
- JQL Builder
|
12 |
- text2jql
|
13 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
- JQL
|
11 |
- JQL Builder
|
12 |
- text2jql
|
13 |
+
---
|
14 |
+
|
15 |
+
|
16 |
+
## Model in Action 🚀
|
17 |
+
|
18 |
+
```python
|
19 |
+
from transformers import AutoModelWithLMHead, AutoTokenizer
|
20 |
+
|
21 |
+
tokenizer = AutoTokenizer.from_pretrained("ManthanKulakarni/Text2JQLBuilder")
|
22 |
+
model = AutoModelWithLMHead.from_pretrained("ManthanKulakarni/Text2JQLBuilder")
|
23 |
+
|
24 |
+
def gen_sentence(words, max_length=32):
|
25 |
+
input_text = words
|
26 |
+
features = tokenizer([input_text], return_tensors='pt')
|
27 |
+
|
28 |
+
output = model.generate(input_ids=features['input_ids'],
|
29 |
+
attention_mask=features['attention_mask'],
|
30 |
+
max_length=max_length)
|
31 |
+
|
32 |
+
return tokenizer.decode(output[0], skip_special_tokens=True)
|
33 |
+
|
34 |
+
words = "JQL: all story under project ACM"
|
35 |
+
|
36 |
+
gen_sentence(words)
|
37 |
+
|
38 |
+
# output: 'JQL: project = CM'
|
39 |
+
```
|