Views
No views yet

1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from transformers.generation.utils import GenerationConfig
4
5tokenizer = AutoTokenizer.from_pretrained("FarReelAILab/Machine_Mindset_en_ISTP", use_fast=False, trust_remote_code=True)
6model = AutoModelForCausalLM.from_pretrained("FarReelAILab/Machine_Mindset_en_ISTP", device_map="auto", torch_dtype=torch.float16, trust_remote_code=True)
7model.generation_config = GenerationConfig.from_pretrained("FarReelAILab/Machine_Mindset_en_ISTP")
8
9messages = []
10messages.append({"role": "user", "content": "What is your MBTI personality type?"})
11response = model.chat(tokenizer, messages)
12print(response)
13
14messages.append({'role': 'assistant', 'content': response})
15messages.append({"role": "user", "content": "After spending a day with a group of people, how do you feel when you return home?"})
16response = model.chat(tokenizer, messages)
17print(response)1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from transformers.generation.utils import GenerationConfig
4tokenizer = AutoTokenizer.from_pretrained("FarReelAILab/Machine_Mindset_en_ISTP", use_fast=False, trust_remote_code=True)
5model = AutoModelForCausalLM.from_pretrained("FarReelAILab/Machine_Mindset_en_ISTP", device_map="auto", torch_dtype=torch.float16, trust_remote_code=True)
6model.generation_config = GenerationConfig.from_pretrained("FarReelAILab/Machine_Mindset_en_ISTP")
7messages = []
8print("####Enter 'exit' to exit.")
9print("####Enter 'clear' to clear the chat history.")
10while True:
11 user=str(input("User:"))
12 if user.strip()=="exit":
13 break
14 elif user.strip()=="clear":
15 messages=[]
16 continue
17 messages.append({"role": "user", "content": user})
18 response = model.chat(tokenizer, messages)
19 print("Assistant:", response)
20 messages.append({"role": "assistant", "content": str(response)})1git clone https://github.com/hiyouga/LLaMA-Factory.git
2cd LLaMA-Factory
3python ./src/cli_demo.py \
4 --model_name_or_path /path_to_your_local_model \
5 --template llama2@article{cui2023machine,
title={Machine Mindset: An MBTI Exploration of Large Language Models},
author={Cui, Jiaxi and Lv, Liuzhenghao and Wen, Jing and Tang, Jing and Tian, YongHong and Yuan, Li},
journal={arXiv preprint arXiv:2312.12999},
year={2023}
}