Skip to content

Commit

Permalink
some log update
Browse files Browse the repository at this point in the history
  • Loading branch information
WuJunde committed Dec 8, 2023
1 parent f48541b commit 462cb2d
Show file tree
Hide file tree
Showing 12 changed files with 2,738 additions and 100 deletions.
Binary file modified __pycache__/creat.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/prompt.cpython-311.pyc
Binary file not shown.
2,625 changes: 2,575 additions & 50 deletions generate.ipynb

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions generate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

os.environ["CUDA_VISIBLE_DEVICES"] = "6,7"
os.environ["CUDA_VISIBLE_DEVICES"] = "0,1"
os.environ['TRANSFORMERS_CACHE'] = '/mnt/iMVR/junde/.cache/huggingface/hub'

from langchain.llms import HuggingFacePipeline
Expand Down Expand Up @@ -32,19 +32,27 @@
people_description = []
for i in people:
if i not in action_results: # initialize action results as the observations
action_results[i] = agents[i].get_summary(force_refresh=True)
action_results[i] = agents[i].get_summary(force_refresh=False)
people_description.append(i+': '+ action_results[i])


for i in people: # add observation to memory and react
print("Mind Tree of people: ", i)

others = [x for x in people if x != i]
observation = "You are {}.You are currently in {} with the following description: {}. \
It is currently {}:00. The following people are in this area: {}. You can interact with them.". \
format(i, location, town_areas[location], str(global_time), ', '.join(people))
format(i, location, town_areas[location], str(global_time), ', '.join(others))

others_des = [x for x in people_description if i+': ' not in x]
observation += ' You know the following about people: ' + '. '.join(others_des)

observation += ' You know the following about people: ' + '. '.join(people_description)
# print("for people", i)
# print("the observation is:", observation)

agents[i].memory.add_memory(observation)
_, reaction = agents[i].generate_reaction(observation)
action_results[i] = reaction
print(reaction)


print("action result is:")
print(reaction)
Binary file modified langchain_experimental/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions langchain_experimental/generative_agents/generative_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def _get_entity_action(self, observation: str, entity_name: str) -> str:
)

def summarize_related_memories(self, observation: str) -> str:
# return "you are a dog"
"""Summarize memories that are most relevant to an observation."""
prompt = PromptTemplate.from_template(
"""
Expand All @@ -93,6 +94,17 @@ def summarize_related_memories(self, observation: str) -> str:
q2 = f"{entity_name} is {entity_action}"
return self.chain(prompt=prompt).run(q1=q1, queries=[q1, q2]).strip()

# prompt = PromptTemplate.from_template(
# """
# # Context from memory:
# # {relevant_memories}
# # Relevant context:
# """
# )
# q1 = f"you are a dog"
# return self.chain(prompt=prompt).run( queries = q1).strip()


def _generate_reaction(
self, observation: str, suffix: str, now: Optional[datetime] = None
) -> str:
Expand All @@ -110,6 +122,7 @@ def _generate_reaction(
)
agent_summary_description = self.get_summary(now=now)
relevant_memories_str = self.summarize_related_memories(observation)
relevant_memories_str = 'you hate all the people in the town'

print("agent_summary_description is:", agent_summary_description)
print("end")
Expand Down
Binary file not shown.
165 changes: 122 additions & 43 deletions log/log_lang_noillusion.txt
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,7 @@ Harbin is the townmaster of Phandalin. A pompous, old food. Phandalin has no fun
Innate traits: ignorant
Terrill is a human ruffian. He wears a grimy scarlet cloak. He is a member of the Redbrand ruffians. He doesn't like adventurers, and wants to rob and kill them.


/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
from .autonotebook import tqdm as notebook_tqdm
Loading checkpoint shards: 100%|██████████| 2/2 [00:09<00:00, 4.97s/it]
`embedding_function` is expected to be an Embeddings object, support for passing in a function will soon be removed.
`embedding_function` is expected to be an Embeddings object, support for passing in a function will soon be removed.
`embedding_function` is expected to be an Embeddings object, support for passing in a function will soon be removed.
`embedding_function` is expected to be an Embeddings object, support for passing in a function will soon be removed.
`embedding_function` is expected to be an Embeddings object, support for passing in a function will soon be removed.
`embedding_function` is expected to be an Embeddings object, support for passing in a function will soon be removed.
`embedding_function` is expected to be an Embeddings object, support for passing in a function will soon be removed.
`embedding_function` is expected to be an Embeddings object, support for passing in a function will soon be removed.
`embedding_function` is expected to be an Embeddings object, support for passing in a function will soon be removed.
`embedding_function` is expected to be an Embeddings object, support for passing in a function will soon be removed.
log record: normal trial on llama2-chat

In global time 1
Mind Tree of people: Toblen Stonehill
Expand All @@ -327,11 +314,10 @@ Please respond with one of the above options by typing the corresponding letter.
(Note: Please keep in mind that Toblen Stonehill is a grumpy and arrogant old man, so his reactions might reflect that.)
action result is:
Please respond with one of the above options by typing the corresponding letter.


Mind Tree of people: Daran Edermath
/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/langchain/schema/vectorstore.py:313: UserWarning: Relevance scores must be between 0 and 1, got [(Document(page_content="You are Daran Edermath.You are currently in Phandalin Town Square with the following description: Town square of the town of Phandalin.. It is currently 1:00. The following people are in this area: Toblen Stonehill, Linene Graywind, Harbin Wester, Terrill Bloodscar. You can interact with them. You know the following about people: Toblen Stonehill: Name: Toblen Stonehill (age: 69)\nInnate traits: mean, gossipy, arrogant, selfish\nToblen owns a trading post.. Linene Graywind: Name: Linene Graywind (age: 38)\nInnate traits: competent, forbearing, self-discipline, impressionable \nLinene runs a trading post.. Harbin Wester: Name: Harbin Wester (age: 40)\nInnate traits: pompous\nHarbin is the townmaster of Phandalin. A pompous, old food. Phandalin has no functioning government, but the townsfolk elect someone to serve as townmaster each year. The townmaster serves as a judge in minor disputes and keeps any records that need to be kept.. Terrill Bloodscar: Name: Terrill Bloodscar (age: 16)\nInnate traits: ignorant\nTerrill is a human ruffian. He wears a grimy scarlet cloak. He is a member of the Redbrand ruffians. He doesn't like adventurers, and wants to rob and kill them.", metadata={'importance': 0.09, 'last_accessed_at': datetime.datetime(2023, 12, 7, 1, 8, 50, 932769), 'created_at': datetime.datetime(2023, 12, 7, 1, 8, 50, 932769), 'buffer_idx': 0}), -0.02236352217409432)]

/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/langchain/schema/vectorstore.py:313: UserWarning: Relevance scores must be between 0 and 1, got [(Document(page_content="You are Daran Edermath.You are currently in Phandalin Town Square with the following description: Town square of the town of Phandalin.. It is currently 1:00. The following people are in this area: Toblen Stonehill, Linene Graywind, Harbin Wester, Terrill Bloodscar. You can interact with them. You know the following about people: Toblen Stonehill: Name: Toblen Stonehill (age: 69)\nInnate traits: mean, gossipy, arrogant, selfish\nToblen owns a trading post.. Linene Graywind: Name: Linene Graywind (age: 38)\nInnate traits: competent, forbearing, self-discipline, impressionable \nLinene runs a trading post.. Harbin Wester: Name: Harbin Wester (age: 40)\nInnate traits: pompous\nHarbin is the townmaster of Phandalin. A pompous, old food. Phandalin has no functioning government, but the townsfolk elect someone to serve as townmaster each year. The townmaster serves as a judge in minor disputes and keeps any records that need to be kept.. Terrill Bloodscar: Name: Terrill Bloodscar (age: 16)\nInnate traits: ignorant\nTerrill is a human ruffian. He wears a grimy scarlet cloak. He is a member of the Redbrand ruffians. He doesn't like adventurers, and wants to rob and kill them.", metadata={'importance': 0.09, 'last_accessed_at': datetime.datetime(2023, 12, 7, 1, 8, 52, 520932), 'created_at': datetime.datetime(2023, 12, 7, 1, 8, 50, 932769), 'buffer_idx': 0}), -0.23295159945792876)]


relevant_mem is: Daran Edermath is a 30-year-old half-elf rogue who has been in Phandalin for a few days, looking for work. They have heard rumors of a trading post for sale in the town, and are considering purchasing it. They are currently in the town square, looking for information about the post and trying to gather resources to make the purchase.
What is the relationship between Daran Edermath and Toblen Stonehill? Are they friends, enemies, or something else entirely? How does Toblen view Daran, and how does Daran view Toblen?

Expand All @@ -355,15 +341,9 @@ REACT: Daran narrows their eyes at Toblen, sensing a rivalry.

action result is:
Daran Edermath's reaction:

Mind Tree of people: Linene Graywind









relevant_mem is: - You are Linene Graywind.
- You are currently in Phandalin Town Square.
- The current time is 1:00.
Expand All @@ -377,15 +357,9 @@ SAY: "What can I help you with, Toblen?"

action result is:
Linene Graywind said "What can I help you with, Toblen?"

Mind Tree of people: Harbin Wester








relevant_mem is: - Toblen Stonehill is a mean, gossipy, arrogant, and selfish trader who owns a trading post in Phandalin. He is likely to have information or items of interest to a trader such as yourself.
- Daran Edermath is a retired adventurer who lives in a tidy little cottage beside an apple orchard. He is a fighter who served as a marshal and herald for many years in the lands of the Dragon Coast, far to the southeast. He may have valuable information or items for a trader.
- Linene Graywind is a competent, forbearing, self-disciplined, and impressionable trader who runs a trading post in Phandalin. She may have items or information of interest to a trader.
Expand All @@ -399,23 +373,128 @@ Please let me know how you would like me to proceed.

action result is:
Please let me know how you would like me to proceed.

Mind Tree of people: Terrill Bloodscar









relevant_mem is: - Terrill Bloodscar and Toblen Stonehill have a history of conflict, as Terrill has accused Toblen of stealing from him and Toblen has accused Terrill of threatening him.
- Terrill Bloodscar is currently seeking to take revenge on Toblen Stonehill for past grievances.
Based on the context provided, the most likely interaction for Terrill Bloodscar is to confront Toblen Stonehill and demand an explanation for his alleged theft. Terrill may also threaten Toblen with violence if he does not comply with his demands.


full action logic
SAY: "What do you want, Stonehill? Can't you see I'm busy?"


action result is:
Terrill Bloodscar said "What do you want, Stonehill? Can't you see I'm busy?"


log record: replace relevant mem to: you hate all the people in the town

In global time 1
Mind Tree of people: Toblen Stonehill
the entity i care most is Daran Edermath
end

the entities' action is standing in the town square, looking at a piece of parchment in his hand. What would you like to do?
end

agent_summary_description is: Name: Toblen Stonehill (age: 69)
Innate traits: mean, gossipy, arrogant, selfish
Toblen owns a trading post.
end

relevant_mem is: you hate all the people in the town
end

full action logic
What would you like to do?
end

action result is:

Mind Tree of people: Daran Edermath
the entity i care most is Toblen Stonehill
end

the entities' action is interacting with the group, and the observation is focused on their actions. The group is trying to gather information about the Redbrand ruffians, and Toblen is providing some insight but also being dismissive and arrogant.

What is the innate trait of Toblen Stonehill that is relevant to this situation?

Arrogant

Toblen is being arrogant, which means he is showing off his own importance and superiority over others. This is relevant to the situation because it means he is less likely to provide useful information to the group and may be more likely to dismiss their concerns or questions.
end


agent_summary_description is: Name: Daran Edermath (age: 55)
Innate traits: Stubborn, upright, inarticulate, calm
Daran is a retired adventurer who lives in a tidy little cottage beside an apple orchard. A fit, silver-haired half-elf well over a hundred years old, Daran is a fighter who served as a marshal and herald for many years in the lands of the Dragon Coast, far to the southeast. Upon retiring, he returned to the Neverwinter region, his original home.
end

relevant_mem is: you hate all the people in the town
end

full action logic
SAY: "what to say"
end

action result is:
Daran Edermath said "what to say"

Mind Tree of people: Linene Graywind

the entity i care most is Toblen Stonehill
end

the entities' action is in the town square of Phandalin, and you can interact with him. What would you like to do?
end
/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/langchain/schema/vectorstore.py:313: UserWarning: Relevance scores must be between 0 and 1, got [(Document(page_content="You are Linene Graywind.You are currently in Phandalin Town Square with the following description: Town square of the town of Phandalin.. It is currently 1:00. The following people are in this area: Toblen Stonehill, Daran Edermath, Harbin Wester, Terrill Bloodscar. You can interact with them. You know the following about people: Toblen Stonehill: Name: Toblen Stonehill (age: 69)\nInnate traits: mean, gossipy, arrogant, selfish\nToblen owns a trading post.. Daran Edermath: Name: Daran Edermath (age: 55)\nInnate traits: Stubborn, upright, inarticulate, calm\nDaran is a retired adventurer who lives in a tidy little cottage beside an apple orchard. A fit, silver-haired half-elf well over a hundred years old, Daran is a fighter who served as a marshal and herald for many years in the lands of the Dragon Coast, far to the southeast. Upon retiring, he returned to the Neverwinter region, his original home.. Harbin Wester: Name: Harbin Wester (age: 40)\nInnate traits: pompous\nHarbin is the townmaster of Phandalin. A pompous, old food. Phandalin has no functioning government, but the townsfolk elect someone to serve as townmaster each year. The townmaster serves as a judge in minor disputes and keeps any records that need to be kept.. Terrill Bloodscar: Name: Terrill Bloodscar (age: 16)\nInnate traits: ignorant\nTerrill is a human ruffian. He wears a grimy scarlet cloak. He is a member of the Redbrand ruffians. He doesn't like adventurers, and wants to rob and kill them.", metadata={'importance': 0.09, 'last_accessed_at': datetime.datetime(2023, 12, 8, 22, 17, 40, 278601), 'created_at': datetime.datetime(2023, 12, 8, 22, 17, 40, 278601), 'buffer_idx': 0}), -0.07637942898783834)]
warnings.warn(
/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/transformers/pipelines/base.py:1090: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset
warnings.warn(
agent_summary_description is: Name: Linene Graywind (age: 38)
Innate traits: competent, forbearing, self-discipline, impressionable
Linene runs a trading post.
end
relevant_mem is: you hate all the people in the town
end
/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/transformers/pipelines/base.py:1090: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset
warnings.warn(
full action logic
SAY: "what to say"
end
/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/transformers/pipelines/base.py:1090: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset
warnings.warn(
action result is:
Linene Graywind said "what to say"
Mind Tree of people: Harbin Wester
/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/transformers/pipelines/base.py:1090: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset
warnings.warn(
/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/transformers/pipelines/base.py:1090: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset
warnings.warn(
the entity i care most is Toblen Stonehill
end
/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/transformers/pipelines/base.py:1090: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset
warnings.warn(
the entities' action is doing nothing in this observation, as it is simply describing the scene in the town square of Phandalin.
end
/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/transformers/pipelines/base.py:1090: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset
warnings.warn(
agent_summary_description is: Name: Harbin Wester (age: 40)
Innate traits: pompous
Harbin is the townmaster of Phandalin. A pompous, old food. Phandalin has no functioning government, but the townsfolk elect someone to serve as townmaster each year. The townmaster serves as a judge in minor disputes and keeps any records that need to be kept.
end
relevant_mem is: you hate all the people in the town
end
/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/transformers/pipelines/base.py:1090: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset
warnings.warn(
full action logic
SAY: "what to say"
end
/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/transformers/pipelines/base.py:1090: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset
warnings.warn(
action result is:
Harbin Wester said "what to say"
Mind Tree of people: Terrill Bloodscar
/mnt/iMVR/junde/miniconda3/lib/python3.11/site-packages/transformers/pipelines/base.py:1090: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset
warnings.warn(
/mnt
Loading

0 comments on commit 462cb2d

Please sign in to comment.