brunneis commited on
Commit
086b94b
1 Parent(s): 6c06757

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +27 -1
README.md CHANGED
@@ -4,4 +4,30 @@ datasets:
4
  - AlfredPros/smart-contracts-instructions
5
  tags:
6
  - ibm-granite/granite-8b-code-instruct
7
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  - AlfredPros/smart-contracts-instructions
5
  tags:
6
  - ibm-granite/granite-8b-code-instruct
7
+ ---
8
+
9
+ ```python
10
+ import torch
11
+ from transformers import AutoModelForCausalLM, AutoTokenizer
12
+ device = "cuda"
13
+ model_path = "braindao/iq-code-evmind-v1-granite-8b-instruct"
14
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
15
+ model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
16
+ model.eval()
17
+
18
+ chat = [
19
+ {
20
+ "role": "user",
21
+ "content": "Create a smart contract to serve as a centralized review system called ReviewHub. This contract should allow users to submit and manage reviews for various products or services, rate them on a scale of 1 to 5, and provide detailed comments. It should include functionalities for assigning unique identifiers to products or services, storing and retrieving reviews, allowing users to edit or delete their reviews, calculating average ratings, and enabling an administrator to moderate content. The contract must incorporate robust security measures to ensure review integrity and prevent spam or malicious activity."
22
+ },
23
+ ]
24
+
25
+ chat = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
26
+ input_tokens = tokenizer(chat, return_tensors="pt")
27
+ for i in input_tokens:
28
+ input_tokens[i] = input_tokens[i].to(device)
29
+ output = model.generate(**input_tokens, max_new_tokens=4096)
30
+ output = tokenizer.batch_decode(output)
31
+ for i in output:
32
+ print(i)
33
+ ```