Commit
•
c192c55
1
Parent(s):
7d560a9
Updated Model Usage
Browse files
README.md
CHANGED
@@ -5,4 +5,89 @@ language:
|
|
5 |
- en
|
6 |
metrics:
|
7 |
- bleu
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
- en
|
6 |
metrics:
|
7 |
- bleu
|
8 |
+
tags:
|
9 |
+
- text2text-generation
|
10 |
+
---
|
11 |
+
# Usage
|
12 |
+
|
13 |
+
Plese find below example how to generate cover letter for input.
|
14 |
+
|
15 |
+
### Running the model on a GPU
|
16 |
+
|
17 |
+
|
18 |
+
```python
|
19 |
+
|
20 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
21 |
+
|
22 |
+
tokenizer = T5Tokenizer.from_pretrained("ShashiVish/t5-base-fine-tune-1024-cover-letter")
|
23 |
+
model = T5ForConditionalGeneration.from_pretrained("ShashiVish/t5-base-fine-tune-1024-cover-letter" , max_length = 512 , device_map="auto")
|
24 |
+
|
25 |
+
job_title = "Senior Java Developer"
|
26 |
+
preferred_qualification = "3+ years of Java, Spring Boot"
|
27 |
+
hiring_company_name = "Google"
|
28 |
+
user_name = "Emily Evans"
|
29 |
+
past_working_experience= "Java Developer at XYZ for 4 years"
|
30 |
+
current_working_experience = "Senior Java Developer at ABC for 1 year"
|
31 |
+
skilleset= "Java, Spring Boot, Microservices, SQL, AWS"
|
32 |
+
qualification = "Master's in Electronics Science"
|
33 |
+
|
34 |
+
|
35 |
+
input_text = f" Generate Cover Letter for Role: {job_title}, \
|
36 |
+
Preferred Qualifications: {preferred_qualification}, \
|
37 |
+
Hiring Company: {hiring_company_name}, User Name: {user_name}, \
|
38 |
+
Past Working Experience: {past_working_experience}, Current Working Experience: {current_working_experience}, \
|
39 |
+
Skillsets: {skilleset}, Qualifications: {qualification} "
|
40 |
+
|
41 |
+
# Tokenize and generate predictions
|
42 |
+
input_ids = tokenizer.encode(input_text, return_tensors='pt', max_length=2048, truncation=False, padding=True)
|
43 |
+
input_ids = input_ids.to('cuda')
|
44 |
+
output_ids = model.generate(input_ids)
|
45 |
+
|
46 |
+
# Decode the output
|
47 |
+
output_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
48 |
+
|
49 |
+
print("Generated Cover Letter:")
|
50 |
+
print(output_text)
|
51 |
+
|
52 |
+
```
|
53 |
+
|
54 |
+
|
55 |
+
### Running the model on a CPU
|
56 |
+
|
57 |
+
|
58 |
+
```python
|
59 |
+
|
60 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
61 |
+
|
62 |
+
tokenizer = T5Tokenizer.from_pretrained("ShashiVish/t5-base-fine-tune-1024-cover-letter")
|
63 |
+
model = T5ForConditionalGeneration.from_pretrained("ShashiVish/t5-base-fine-tune-1024-cover-letter" , max_length = 512 )
|
64 |
+
|
65 |
+
job_title = "Senior Java Developer"
|
66 |
+
preferred_qualification = "3+ years of Java, Spring Boot"
|
67 |
+
hiring_company_name = "Google"
|
68 |
+
user_name = "Emily Evans"
|
69 |
+
past_working_experience= "Java Developer at XYZ for 4 years"
|
70 |
+
current_working_experience = "Senior Java Developer at ABC for 1 year"
|
71 |
+
skilleset= "Java, Spring Boot, Microservices, SQL, AWS"
|
72 |
+
qualification = "Master's in Electronics Science"
|
73 |
+
|
74 |
+
|
75 |
+
input_text = f" Generate Cover Letter for Role: {job_title}, \
|
76 |
+
Preferred Qualifications: {preferred_qualification}, \
|
77 |
+
Hiring Company: {hiring_company_name}, User Name: {user_name}, \
|
78 |
+
Past Working Experience: {past_working_experience}, Current Working Experience: {current_working_experience}, \
|
79 |
+
Skillsets: {skilleset}, Qualifications: {qualification} "
|
80 |
+
|
81 |
+
# Tokenize and generate predictions
|
82 |
+
input_ids = tokenizer.encode(input_text, return_tensors='pt', max_length=2048, truncation=False, padding=True)
|
83 |
+
output_ids = model.generate(input_ids)
|
84 |
+
|
85 |
+
# Decode the output
|
86 |
+
output_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
87 |
+
|
88 |
+
print("Generated Cover Letter:")
|
89 |
+
print(output_text)
|
90 |
+
|
91 |
+
```
|
92 |
+
|
93 |
+
|