quangbk / generativeagent_llm Goto Github PK
View Code? Open in Web Editor NEWImplementation of "Generative Agents: Interactive Simulacra of Human Behavior" paper with Guidance and Langchain. Full features and work with local LLMs.
License: Other
Implementation of "Generative Agents: Interactive Simulacra of Human Behavior" paper with Guidance and Langchain. Full features and work with local LLMs.
License: Other
sam_observations = [
"Sam wake up in the morning",
]
sam.add_memories(sam_observations)
summary = sam.get_summary(force_refresh=True)
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <cell line: 1>:1 │
│ │
│ /content/generativeAgent_LLM/server/generativeAgent.py:163 in get_summary │
│ │
│ 160 │ │ │ or since_refresh >= self.summary_refresh_seconds │
│ 161 │ │ │ or force_refresh │
│ 162 │ │ ): │
│ ❱ 163 │ │ │ core_characteristics = self._run_characteristics() │
│ 164 │ │ │ daily_occupation = self._run_occupation() │
│ 165 │ │ │ feeling = self._run_feeling() │
│ 166 │
│ │
│ /content/generativeAgent_LLM/server/generativeAgent.py:173 in _run_characteristics │
│ │
│ 170 │ │ return self.summary │
│ 171 │ │
│ 172 │ def _run_characteristics(self,): │
│ ❱ 173 │ │ docs = self.retriever.get_relevant_documents(self.name + "'s core characteristic │
│ 174 │ │ statements = get_text_from_docs(docs, include_time = False) │
│ 175 │ │ │
│ 176 │ │ prompt = self.guidance(PROMPT_CHARACTERISTICS, silent=self.silent) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: BaseRetriever.get_relevant_documents() takes 2 positional arguments but 3 were given
I can get around this by making def get_relevant_documents(self, query: str, current_time=None)
and invoking
with mock_now(datetime.datetime(2011, 2, 3, 10, 11)):
print(sam.retriever.get_relevant_documents("sam's core characteristics")
[Document(page_content='Sam is a Ph.D student, his major is CS', metadata={'importance': 7, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 0}), Document(page_content='Sam likes computer', metadata={'importance': 1, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 1}), Document(page_content='Wants to get his AI company to be successful.', metadata={'importance': 8, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 5}), Document(page_content='Sam really wants to get to work to get the marketing project for his AI company done', metadata={'importance': 3, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 7}), Document(page_content='Sam wake up in the morning', metadata={'importance': 1, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 6}), Document(page_content='Sam has a dog, named Max', metadata={'importance': 1, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 4}), Document(page_content="Sam's farther is a doctor", metadata={'importance': 1, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 3}), Document(page_content='Sam lives with his friend, Bob', metadata={'importance': 1, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 2})]
I really don't understand the issue - is it the timestamp passed?
The method _get_combined_score_list
in TimeWeightedVectorStoreRetrieverModified
class has this:
generativeAgent_LLM/server/time_weighted_retriever.py
Lines 91 to 93 in 17d67f6
The original implementation in Langchain adds vector_relevance
but why do you add 1-vertor_relevance
here
Hi, can someone share requirements.txt , env.yaml /toml, or and sort of environment setup file for cuda 12.1. I have access to a cloud server but unable to change the cuda version.
model=TheBloke_Llama-2-13B-GPTQ/model.safetensors, I also tried: Wizard-Vicuna-7B-Uncensored-GPTQ-4bit-128g.no-act-order.safetensors, same problem
Loading model ...
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[36], line 5
1 # MODEL_PATH = '/home/quang/working/LLMs/oobabooga_linux/text-generation-webui/models/TheBloke_Wizard-Vicuna-7B-Uncensored-GPTQ'
2 # CHECKPOINT_PATH = '/home/quang/working/LLMs/oobabooga_linux/text-generation-webui/models/TheBloke_Wizard-Vicuna-7B-Uncensored-GPTQ/Wizard-Vicuna-7B-Uncensored-GPTQ-4bit-128g.no-act-order.safetensors'
4 DEVICE = torch.device('cuda:0')
----> 5 model, tokenizer = load_model_main(MODEL_PATH, CHECKPOINT_PATH, DEVICE)
File /mnt/data/generativeAgent_LLM/server/model.py:56, in load_model_main(model_para, checkpoint_para, device)
55 def load_model_main(model_para, checkpoint_para, device):
---> 56 model = load_quant(model_para, checkpoint_para, 4, 128)
57 model.to(device)
58 tokenizer = AutoTokenizer.from_pretrained(model_para)
File /mnt/data/generativeAgent_LLM/server/model.py:47, in load_quant(model, checkpoint, wbits, groupsize)
45 if checkpoint.endswith('.safetensors'):
46 from safetensors.torch import load_file as safe_load
---> 47 model.load_state_dict(safe_load(checkpoint))
48 else:
49 model.load_state_dict(torch.load(checkpoint))
File ~/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py:1671, in Module.load_state_dict(self, state_dict, strict)
1666 error_msgs.insert(
1667 0, 'Missing key(s) in state_dict: {}. '.format(
1668 ', '.join('"{}"'.format(k) for k in missing_keys)))
1670 if len(error_msgs) > 0:
-> 1671 raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
1672 self.__class__.__name__, "\n\t".join(error_msgs)))
1673 return _IncompatibleKeys(missing_keys, unexpected_keys)
RuntimeError: Error(s) in loading state_dict for LlamaForCausalLM:
Unexpected key(s) in state_dict: "model.layers.0.self_attn.rotary_emb.inv_freq", "model.layers.0.self_attn.k_proj.g_idx", "model.layers.0.self_attn.o_proj.g_idx", "model.layers.0.self_attn.q_proj.g_idx", "model.layers.0.self_attn.v_proj.g_idx", "model.layers.0.mlp.down_proj.g_idx", "model.layers.0.mlp.gate_proj.g_idx", "model.layers.0.mlp.up_proj.g_idx", "model.layers.1.self_attn.rotary_emb.inv_freq", "model.layers.1.self_attn.k_proj.g_idx", "model.layers.1.self_attn.o_proj.g_idx", "model.layers.1.self_attn.q_proj.g_idx", "model.layers.1.self_attn.v_proj.g_idx", "model.layers.1.mlp.down_proj.g_idx", "model.layers.1.mlp.gate_proj.g_idx", "model.layers.1.mlp.up_proj.g_idx", "model.layers.2.self_attn.rotary_emb.inv_freq", "model.layers.2.self_attn.k_proj.g_idx", "model.layers.2.self_attn.o_proj.g_idx", "model.layers.2.self_attn.q_proj.g_idx", "model.layers.2.self_attn.v_proj.g_idx", "model.layers.2.mlp.down_proj.g_idx", "model.layers.2.mlp.gate_proj.g_idx",
### Instruction:
{{recent_memories}}
### Input:
Given only the information above, what are 3 most salient high-level questions we can answer about the subjects in the statements?
### Response:
{{#geneach 'items' num_iterations=3}}{{gen 'this' top_k=30 top_p=0.18 repetition_penalty=1.15 temperature=1.99 stop='
'}}
{{/geneach}}
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <cell line: 6>:6 │
│ │
│ /content/generativeAgent_LLM/server/generativeAgent.py:122 in add_memories │
│ │
│ 119 │ │ │
│ 120 │ │ if not self.reflecting and self.aggregate_importance > self.reflection_threshold │
│ 121 │ │ │ self.reflecting = True │
│ ❱ 122 │ │ │ self._relection() │
│ 123 │ │ │ self.aggregate_importance = 0.0 │
│ 124 │ │ │ self.reflecting = False │
│ 125 │
│ │
│ /content/generativeAgent_LLM/server/generativeAgent.py:144 in _relection │
│ │
│ 141 │ │ return result['items'] │
│ 142 │ │
│ 143 │ def _relection(self,): │
│ ❱ 144 │ │ list_salient = self._get_salient() │
│ 145 │ │ list_docs = [] │
│ 146 │ │ for salient_temp in list_salient: │
│ 147 │ │ │ docs = self.retriever.get_relevant_documents(salient_temp, self.get_current_ │
│ │
│ /content/generativeAgent_LLM/server/generativeAgent.py:134 in _get_salient │
│ │
│ 131 │ │ │
│ 132 │ │ prompt = self.guidance(PROMPT_SALIENT, silent=self.silent) │
│ 133 │ │ result = prompt(recent_memories=recent_memories_text) │
│ ❱ 134 │ │ return result['items'] │
│ 135 │ │
│ 136 │ def _get_insights(self, list_docs): │
│ 137 │ │ docs = list_docs │
│ │
│ /usr/local/lib/python3.10/dist-packages/guidance/_program.py:470 in __getitem__ │
│ │
│ 467 │ │ │ self._execute_complete.set() │
│ 468 │ │
│ 469 │ def __getitem__(self, key): │
│ ❱ 470 │ │ return self._variables[key] │
│ 471 │ │
│ 472 │ def __contains__(self, key): │
│ 473 │ │ return key in self._variables │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
KeyError: 'items'
result is actually this string
### Instruction:
{{recent_memories}}
### Input:
Given only the information above, what are 3 most salient high-level questions we can answer about the subjects in the statements?
### Response:
{{#geneach 'items' num_iterations=3}}{{gen 'this' top_k=30 top_p=0.18 repetition_penalty=1.15 temperature=1.99 stop='
'}}
{{/geneach}}
adding a single memory seems to work
Did you start working on the idea of the "simulation loop"? What I don't get from the paper (where they also have spatial movement): is there a world-state including a world tick, or how would the loop look like, do agents decide what to do next (reflect, obsever, ...) or is this a pre-programmed script when implemented.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.