紙的開源LLM實施:
recurrentgpt:(任意)長文本的交互式生成。
[紙] [arxiv] [huggingface] [ofstical]
變壓器的固定尺寸上下文使GPT模型無法生成任意長的文本。在本文中,我們引入了RecurrentGpt,這是RNN中復發機制的基於語言的模擬。 recurrentgpt建立在大型語言模型(LLM)(例如Chatgpt)上,並使用自然語言模擬LSTM中的長期短期記憶機制。在每個時間段上,RecurrentGpt生成文本段落,並分別更新其基於語言的長期記憶內存儲在硬盤驅動器和提示上的長期記憶。這種複發機制使得可以復發能夠生成任意長度的文本而不會忘記。由於人類用戶可以輕鬆地觀察和編輯自然語言記憶,因此可以解釋recurrentgpt,並可以互動長期產生。 RecurrentGPT是邁出下一代計算機輔助寫作系統的第一步,而不是本地編輯建議。除了產生AI生成的內容(AIGC)外,我們還證明了將RecurrentGpt用作直接與消費者互動的互動小說的可能性。我們稱``AI''(AIAC)的生成模型使用,我們認為這是常規AIGC的下一種形式。我們進一步證明了使用Recurrentgpt創建個性化互動小說的可能性,該小說直接與讀者互動,而不是與作家互動。從更廣泛的角度來看,Recurrentgpt展示了從認知科學中流行的模型設計和促使LLM的深度學習中藉用思想的實用性。
變壓器的固定尺寸上下文使得gpt模型無法生成任意長的文本。在本文中,我們介紹了,重新定性,一個基於語言的模擬rnns中的遞歸機制。recurrentgpt 建立在大型語言模型( llm)之上,如,如chatgpt,並使用自然語言來模擬lstm中的長短時記憶機制。在每個時間段,recurrentGpt,生成一段文字i作為內容“(
pip install transformers@git+https://github.com/huggingface/transformers.git
pip install peft@git+https://github.com/huggingface/peft.git
pip install accelerate@git+https://github.com/huggingface/accelerate.git
pip install bitsandbytes==0.39.0
pip install -U flagai
pip install bminf
[global_config.py]
lang_opt = "zh" # zh or en. make English or Chinese Novel
llm_model_opt = "openai" # default is openai, it also can be other open-source LLMs as below
您應該先應用OpenAI API密鑰。然後
export OPENAI_API_KEY = "your key"
下載Vicuna型號。並在型號/vicuna_bin.py中進行配置
tokenizer = AutoTokenizer . from_pretrained ( model_name_or_path , trust_remote_code = True )
model_config = AutoConfig . from_pretrained ( model_name_or_path , trust_remote_code = True )
model = AutoModel . from_pretrained ( model_name_or_path , config = model_config , trust_remote_code = True )
tokenizer = AutoTokenizer . from_pretrained ( "baichuan-inc/baichuan-7B" , trust_remote_code = True )
model = AutoModelForCausalLM . from_pretrained ( "baichuan-inc/baichuan-7B" , device_map = "auto" , trust_remote_code = True )
loader = AutoLoader (
"lm" ,
model_dir = state_dict ,
model_name = model_name ,
use_cache = True ,
fp16 = True )
model = loader . get_model ()
tokenizer = loader . get_tokenizer ()
model . eval ()
如果要使用BMINF,請添加代碼如下:
with torch . cuda . device ( 0 ):
model = bminf . wrapper ( model , quantization = False , memory_limit = 2 << 30 )
python gradio_server.py
如果該項目可以幫助您減少開發時間,您可以給我一杯咖啡:)
支付寶(支付寶)
微弱(微信)
麻省理工學院©Kun