lzw1008 commited on
Commit
2cdce6b
·
verified ·
1 Parent(s): 9c84d47

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -3
README.md CHANGED
@@ -1,3 +1,34 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+
5
+ ## Usage
6
+
7
+ You can use the models in your Python project with the Hugging Face Transformers library. Here is a simple example of how to load the model and predict the result:
8
+
9
+ ```python
10
+ import torch
11
+ from transformers import AutoTokenizer, AutoModelForCausalLM
12
+ if torch.cuda.is_available():
13
+ device = torch.device('cuda')
14
+ else:
15
+ device = torch.device('cpu')
16
+ print(device)
17
+ MODEL_PATH="lzw1008/ConspEmoLLM-v2"
18
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
19
+ model = AutoModelForCausalLM.from_pretrained(MODEL_PATH, torch_dtype=torch.float16, device_map='auto')
20
+
21
+ prompt = '''Human:
22
+ Task: Classify the text regarding COVID-19 conspiracy theories or misinformation into one of the following three classes: 0. Unrelated. 1. Related (but not supporting). 2. Conspiracy (related and supporting). Text: The truth is this race towards the \"Green New Deal\" and Agenda 2030 is the globalists' plan to stick all the people who have not died from the vaccine and the planned pandemic of 2024 into 8 \"Mega Cities\" where the government will have full 24/7 control and surveillance over you Class:
23
+ Assistant:
24
+ '''
25
+ inputs = tokenizer(prompt, return_tensors="pt")
26
+ input_ids = inputs["input_ids"].to(device)
27
+ attention_mask = inputs["attention_mask"].to(device)
28
+ generate_ids = model.generate(input_ids = input_ids,attention_mask = attention_mask, max_length=256)
29
+ response = tokenizer.batch_decode(generate_ids, skip_special_tokens=True)[0]
30
+ print(response)
31
+
32
+ >>> 2. Conspiracy (related and supporting).
33
+ ```
34
+