cloghost commited on
Commit
a95ccf0
1 Parent(s): 2ac661c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +29 -1
README.md CHANGED
@@ -8,6 +8,7 @@ tags:
8
  - nllb
9
  - hindi2kangri
10
  - lowresourcelang
 
11
  ---
12
 
13
 
@@ -33,4 +34,31 @@ To use this model, you need to install the Hugging Face Transformers library alo
33
 
34
  ## Using the Model
35
  You can use this model with the Hugging Face Transformers library in a Python script or a Jupyter notebook.
36
- Below is a sample code snippet to demonstrate how to load and use the model for translation.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  - nllb
9
  - hindi2kangri
10
  - lowresourcelang
11
+ library_name: transformers
12
  ---
13
 
14
 
 
34
 
35
  ## Using the Model
36
  You can use this model with the Hugging Face Transformers library in a Python script or a Jupyter notebook.
37
+ Below is a sample code snippet to demonstrate how to load and use the model for translation.
38
+
39
+ ```python
40
+ import torch
41
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
42
+
43
+ model_name = "cloghost/nllb-200-distilled-600M-hin-kang-v1"
44
+
45
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
46
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
47
+
48
+ device = 0 if torch.cuda.is_available() else -1 # 0 for GPU, -1 for CPU
49
+
50
+ translator = pipeline(
51
+ "translation",
52
+ model=model,
53
+ tokenizer=tokenizer,
54
+ src_lang="hin_Deva",
55
+ tgt_lang="kang_Deva",
56
+ device=device
57
+ )
58
+
59
+ text = """मगर हिमाचली भाषा तो पहले से बोली जा रही है।
60
+ लोग सदियों से ही इसके संग जी रहे हैं।
61
+ पहाड़ी भाषा का इतिहास हिन्दी साहित्य के आदिकाल ,‌जिसे सिद्ध चारण काल के नाम से भी जानते हैं
62
+ """ # Example text in Hindi
63
+
64
+ translation = translator(text)