Files changed (1) hide show
  1. README.md +28 -1
README.md CHANGED
@@ -21,4 +21,31 @@ We publicly release the RecGPT models along with their pre-training and fine-tun
21
 
22
  Please cite our paper whenever RecGPT or the datasets are used to help produce published results or are incorporated into other software.
23
 
24
- For further information or requests, please go to [RecGPT's homepage](https://github.com/VinAIResearch/RecGPT)!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  Please cite our paper whenever RecGPT or the datasets are used to help produce published results or are incorporated into other software.
23
 
24
+ For further information or requests, please go to [RecGPT's homepage](https://github.com/VinAIResearch/RecGPT)!
25
+
26
+ ## Usage
27
+ ```python
28
+ from transformers import AutoModelForCausalLM, AutoTokenizer
29
+
30
+ model_path = "vinai/RecGPT-7B-Instruct"
31
+
32
+ tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
33
+ model = AutoModelForCausalLM.from_pretrained(model_path, device_map='auto')
34
+
35
+ prompts = [
36
+ "### Instruction:\nPredict the next item.\nGiven the interaction history of a user with food recipes as follows:\n\nTitle: white cheddar potato gratin\nTitle: possum s cream cheese chocolate chip bread\nTitle: zucchini lasagna lasagne low carb\nTitle: sweet potato and apple casserole\n\n### Response:",
37
+ "### Instruction:\nPredict rating for the last item.\nGiven the interaction history of a user with books as follows:\n\nTitle: Rebooting My Brain: How a Freak Aneurysm Reframed My Life; Author: Visit Amazon's Maria Ross Page; Review: I would recommend this book to everyone! As I read the last page I felt that I wanted it to continue with anniversary updates. There is so much hope wry yen within the pages.; Rating: 5.0/5.0\nTitle: Summer of Firefly Memories (The Loon Lake Series); Author: Visit Amazon's Joan Gable Page; Review: Not as well written or edited as I would have liked but the story did what the author hoped it would do---gave you pause to reflect your own 'firefly memories'. this makes it a success. I look forward to the sequel,; Rating: 5.0/5.0\nTitle: Jon Stewart: Beyond The Moments Of Zen; Author: Visit Amazon's Bruce Watson Page; Review: Jon Stewart is a gift to the ages. Thank you ,Thank you,Thank you. My ears are never tired! long may he rage.; Rating: 5.0/5.0\nTitle: How to Succeed at Aging Without Really Dying; Author: Visit Amazon's Lyla Blake Ward Page; Review: Wonderful, funny, accurate!; Rating: 5.0/5.0\nTitle: Death of an Expert Witness (Adam Dalgliesh Mystery Series #6); Author: Visit Amazon's P. D. James Page; Review: You can always depend on a good read from PD James!; Rating:\n\n### Response:",
38
+ ]
39
+
40
+ for prompt in prompts:
41
+ input_ids = tokenizer(prompt, add_special_tokens=True, return_tensors="pt")["input_ids"].to(model.device)
42
+ output_ids = model.generate(
43
+ input_ids,
44
+ max_new_tokens=128,
45
+ eos_token_id=tokenizer.eos_token_id,
46
+ pad_token_id=tokenizer.pad_token_id,
47
+ )
48
+ response = tokenizer.batch_decode(output_ids[:, input_ids.size(1) :], skip_special_tokens=True)[0].strip()
49
+ print(response)
50
+
51
+ ```