Abinaya Mahendiran
commited on
Commit
•
18f1d33
1
Parent(s):
039fc92
Updated model card
Browse files
README.md
CHANGED
@@ -1,13 +1,58 @@
|
|
1 |
# GPT2-Tamil
|
2 |
|
3 |
-
This repository is created as part of the Flax/Jax community week by Huggingface. The aim of this project is to
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
## Dataset Used
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
##
|
|
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# GPT2-Tamil
|
2 |
|
3 |
+
This repository is created as part of the Flax/Jax community week by Huggingface. The aim of this project is to train a language model using GPT-2 specifically for Tamil language.
|
4 |
|
5 |
+
language:
|
6 |
+
- ta
|
7 |
+
tags:
|
8 |
+
- text-generation
|
9 |
+
license: MIT
|
10 |
+
datasets:
|
11 |
+
- OSCAR
|
12 |
+
- IndicNLP
|
13 |
+
metrics:
|
14 |
+
- Preplexity
|
15 |
+
widget:
|
16 |
+
- text: 'ஒரு ஊரிலே ஒரு காக்கைக்கு'
|
17 |
+
|
18 |
+
## Setup:
|
19 |
+
To setup the project, run the following command,
|
20 |
+
``` pip install -r requirements.txt
|
21 |
+
```
|
22 |
|
23 |
+
## Dataset Used:
|
24 |
+
The GTP-2 model is trained using OSCAR (Tamil) and IndicNLP (Tamil) dataset
|
25 |
+
|
26 |
+
## Train model:
|
27 |
+
To perform training, do the following steps,
|
28 |
|
29 |
+
- Export the model directory (where you want to store the model artifacts like config, tokenizer, etc.)
|
30 |
+
```export MODEL_DIR=<model_dir>
|
31 |
+
```
|
32 |
+
- Create the config.json by running the following command,
|
33 |
+
```python src/create_config.py
|
34 |
+
```
|
35 |
+
- Create the tokenizer by running the following command,
|
36 |
+
```python src/train_tokenizer.py
|
37 |
+
```
|
38 |
+
- Once the config and tokenizer is created, run the following script to start training the flax model
|
39 |
+
```python scripts/train_gpt2-oscar-tamil.sh
|
40 |
+
```
|
41 |
|
42 |
+
## Inference:
|
43 |
+
To perform language generation using the model,
|
44 |
|
45 |
+
- First convert the flax model to pytorch using the following command,
|
46 |
+
```python src/convert_flax_to_pytorch.py
|
47 |
+
```
|
48 |
+
- Use the following snippet to perform language generation,
|
49 |
+
```
|
50 |
+
from transformers import AutoTokenizer, AutoModelWithLMHead, pipeline
|
51 |
+
model_name = 'abinayam/gpt-2-tamil'
|
52 |
+
model = AutoModelWithLMHead.from_pretrained(model_name)
|
53 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
54 |
+
input_text = "ஒரு ஊரிலே ஒரு காக்கைக்கு"
|
55 |
+
max_len = 300
|
56 |
+
generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
|
57 |
+
sequence = generator(input_text, max_length=max_len)
|
58 |
+
```
|