Update README.md
Browse files
README.md
CHANGED
@@ -48,13 +48,15 @@ pip install torch>=2.1.0 datasets>=2.17.0 deepspeed>=0.13.4 accelerate>=0.27.2 t
|
|
48 |
|
49 |
Below is an example using `GNER-LLaMA`
|
50 |
```python
|
|
|
51 |
>>> from transformers import AutoTokenizer, AutoModelForCasualLM
|
52 |
>>> tokenizer = AutoTokenizer.from_pretrained("dyyyyyyyy/GNER-LLaMA-7B")
|
53 |
-
>>> model =
|
54 |
>>> model = model.eval()
|
55 |
>>> instruction_template = "Please analyze the sentence provided, identifying the type of entity for each word on a token-by-token basis.\nOutput format is: word_1(label_1), word_2(label_2), ...\nWe'll use the BIO-format to label the entities, where:\n1. B- (Begin) indicates the start of a named entity.\n2. I- (Inside) is used for words within a named entity but are not the first word.\n3. O (Outside) denotes words that are not part of a named entity.\n"
|
|
|
56 |
>>> entity_labels = ["genre", "rating", "review", "plot", "song", "average ratings", "director", "character", "trailer", "year", "actor", "title"]
|
57 |
-
>>> instruction = f"{instruction_template}\nUse the specific entity tags: {', '.join(
|
58 |
>>> instruction = f"[INST] {instruction} [/INST]"
|
59 |
>>> inputs = tokenizer(instruction, return_tensors="pt").to("cuda")
|
60 |
>>> outputs = model.generate(**inputs, max_new_tokens=640)
|
|
|
48 |
|
49 |
Below is an example using `GNER-LLaMA`
|
50 |
```python
|
51 |
+
>>> import torch
|
52 |
>>> from transformers import AutoTokenizer, AutoModelForCasualLM
|
53 |
>>> tokenizer = AutoTokenizer.from_pretrained("dyyyyyyyy/GNER-LLaMA-7B")
|
54 |
+
>>> model =AutoModelForCasualLM.from_pretrained("dyyyyyyyy/GNER-LLaMA-7B", torch_dtype=torch.bfloat16).cuda()
|
55 |
>>> model = model.eval()
|
56 |
>>> instruction_template = "Please analyze the sentence provided, identifying the type of entity for each word on a token-by-token basis.\nOutput format is: word_1(label_1), word_2(label_2), ...\nWe'll use the BIO-format to label the entities, where:\n1. B- (Begin) indicates the start of a named entity.\n2. I- (Inside) is used for words within a named entity but are not the first word.\n3. O (Outside) denotes words that are not part of a named entity.\n"
|
57 |
+
>>> sentence = "did george clooney make a musical in the 1980s"
|
58 |
>>> entity_labels = ["genre", "rating", "review", "plot", "song", "average ratings", "director", "character", "trailer", "year", "actor", "title"]
|
59 |
+
>>> instruction = f"{instruction_template}\nUse the specific entity tags: {', '.join(entity_labels)} and O.\nSentence: {sentence}"
|
60 |
>>> instruction = f"[INST] {instruction} [/INST]"
|
61 |
>>> inputs = tokenizer(instruction, return_tensors="pt").to("cuda")
|
62 |
>>> outputs = model.generate(**inputs, max_new_tokens=640)
|