Tag: psychology

  • Setting up expectation

    When we meet someone new, our mind instinctively tries to compare them to people we have encountered in the past. We consider their patterns to cluster them into the region where people equip the most similar behaviour – or patterns – in how they talk, act or perceive. Rather than taking the risk of evaluating them entirely from scratch, we rather use these metrics to navigate our trust and relationship expectations. It is as if our brain’s background process is an unsupervised classification model that sorts individuals into the most relevant relationship archetypes we have built over time – then later decides our compute subscription plan is no longer valid after a certain age.

    This post details on replicating the human’s mind into setting up the system design behind Naomi. Docker SDK was used to containerize Naomi application and served over hugging face space. For the sake of convenience the datasets, prompt templates and chat sessions uses Hugging Face dataset repo card. The following table outlines the models setup during the application’s build process.

    • Models – Specifies whether the model are tinkered by me or not.
    • Type of Models – Lists the large language model (LLM) and classifiers imported / built during the setup.
    • Type of Dataset Used for Training – Lists the links to the Hugging Face dataset repositories that were used in training the models.
    ModelsType of modelsType of Dataset used for training
    Pre-trained– Llama3.1
    – Bart Multilabel classifier
    Refer to the hyperlinks
    Custom models (trained by me using small sized datasets)– Target features based on human characteristics like MBTI Chain, Big5
    – Dialogue Intent and Emotions
    – MBTI: https://huggingface.co/datasets/kl08/myers-briggs-type-indicator
    – Dialogue:
    https://huggingface.co/datasets/li2017dailydialog/daily_dialog

    Defining as a Reinforcement Learning problem

    Setting up the chat session for Naomi is extremely similar to mocking an episodic game for an agent in a reinforcement learning environment. On top of Naomi’s build, I was also trying to build a base framework for other conversational agents. This involves using Docker SDK to containerize the application so that it can be easily deployed, extend and integrate with other specifications of the agents.

    Referring to Tom as the conversational agent in production and Naomi as the discussed chatbot in this post, the following table compares the agents’ environment’s variables.

    ComponentFormal DefinitionDefinition in Naomi’s Application (per component)Definition in Tom’s Application (per component)
    AgentThe entity that interacts with the environment and learns to maximize rewards.NaomiThe human’s best friend, Tom (or a different name can be used)
    EnvironmentExternal system where agent interacts, receive states and rewards based on actions.Starts from Dockers Image build session and ends with my next pushA Human’s life time
    EpisodeComplete sequence of interactions from an initial state to a terminal state.Chat Session or a complete chat dialogue1 day of bot’s lifespan
    StateRepresentation of the environment at a given time that the agent observes.One/paired Chat message/s. This depends on the inferencing task which depends on the stages during the chat.An interaction with a human user or agent
    ActionDecision made by the agent per state.– Response Behavior: Expressiveness of Naomi’s response.
    – Chat Behavior: Follow up response Naomi.
    – Actions listed for Naomi
    – Actions based on utility or user request. This refers to other app platforms like Notion, Typeform, .. etc.
    – Actions for the agent to select conditioned to current cognitive state for example: browsing Wikipedia / youtube, social platforms like X, Facebook, Instagram etc.
    ObservationContains all possible observations an agent can perceive from the environment.– During chat streaming: User based features collected per utterance that are used to influence agent’s response behaviour.
    – Post chat or after an episode: Evaluation metrics on the user’s behaviour during the dialogue and approximated category defining the user.
    – During chat streaming: User based features collected per utterance that are used to influence agent’s response behaviour.
    – User based features collected from other sensory tools like sound and imaging tools. These features are used with the linguistic analytics to direct the agent’s next state (e.g. of emotions) or action (e.g. response behaviour or activity)

    Naomi’s Response Behavior

    An agent’s response behavior defines how the next text response is returned given the current observation. The following table compares the response behaviour per state between Naomi and Tom.

    Naomi’s response behaviorTom’s response behavior
    • Expressiveness or engagement represented in the next response.
    • Likelihood of following up the previous sent message with a question i.e. double texting the user. The type of question is also conditional to the control vectors collected from the dialogue.
    • Expressiveness or engagement represented in the next response.
    • Likelihood of following up the previous sent messages with questions, analytical comments, suggestive actions like browsing the web (e.g. run a sub-process in the background to browse the web while interacting with the user). Alike Naomi, type of questions asked is conditional to the dialogue.

    Defining the control vectors

    Suppose the control vectors represent features collected per inferencing state. The control vector differs depending on its collection method – whether as a single utterance from either user or agent, or as an episode. The table below outlines the control vector defined in Naomi’s application.

    InputsUserAgent
    Single utterance (State)User
    – User’s Emotional Intensity / Expressiveness
    – User’s Intent

    Agent’s suggested response:
    – emotional / expressiveness in the agent’s next response based on dialogue inferences up to current state
    – Rule-based methods: involve defining explicit rules, constraints or logic to control the model’s behaviour. For example: an indicator of when the chat has ended.
    – Agent’s emotion states of the current utterance (labelled with BART model – this can be used within a feedback loop with the custom model I built with dialogue datasets)
    Dialogue (Episode)Evaluation metricsEvaluation metrics

    Adaptive Learning Methods

    Reinforcement learning methods are applied to the models prepared during the Dockers build process. This depends on the method of retrieving the control vectors for each task, for example: passing an agent’s utterance to indicate when the episode has ended relies on the vector embeddings of the history datasets (or Naomi’s memory). The challenge lies in determining the optimal method for managing the dataset as it grows to a substantial size.

    Sub repo on GithubHistory data handling
    PromptlessVectors Embeddings for binary classifications: handling the vector embeddings can simply be averaging over the randomly selected samples. Another method would be to model the marginal distribution of the vector embeddings, where the target class and the other class are differentiated based on their density estimates. This can be achieved through probabilistic approaches such as kernel density estimation, Gaussian mixture models, or variational inference, ensuring that the classification captures nuanced variations in the embedding space. Although further trials must be done to compare these methods’ performance over time.

    Tom’s progression · Post 11 of 14

    This post sits in Cognition: Learning · Actions: Tool & Skill Capabilities.

    ← Stop Button Decoding Parameters to persist Language model's emotions →

  • Defining a droid’s emotional space

    Defining a droid’s emotional space

    Refining the construction of the emotional space is essential, as it personalizes the agent’s decision-making process and eases the integration of creative thinking1. Strong emotions can push boundaries of one’s creativity, source2. To succeed in developing my droid’s emotional component, I begin by refining how human emotions are labeled.

    Simplifying the idea to three emotion labels: neutral, positive and negative. My initial idea was:

    neutral vs negative vs positive

    However, ambiguity around the definition of “neutral” emotion complicates predicting a distribution over emotional labels. For example, a person observed in a neutral state might simply appear indifferent, yet this does not rule out the possibility that they were the one who accessed your computer through the open-source SSH login credentials to your terminal.

    This data preparation method is often paired with a popular approach in modeling human emotions: combining a BERT encoder with a multilayer perceptron to predict a set of emotion labels. Typically, this includes a “neutral” state alongside positive and negative emotions. I personally find this approach limiting, as it restricts the model’s potential for broader application.

    The next idea was:

    neutral vs emotional (either positive or negative emotions)

    This prompts an examination of the statement: Positive and negative emotions can coexist in the same space. Determining whether this statement holds true or false depends on one’s perspective on human psychology. Hence, the following lists my thoughts to answering this statement:

    • Statement is true if I believe that a person can experience both positive and negative emotion at the same time.
    • Statement is false if I believe that a person cannot experience both emotions at the same time, i.e. I believe that one emotion label is better than the rest.

    The first statement would suggest that the feelings of ‘joyful’ and ‘sad’ are not mutually exclusive which contradicts my common sense. Moreover, the second statement would prompt the challenge in deciphering whether an emotion state is truly considered as negative or positive. This is relative to the context in discussion or the observing state3.

    Brainstormed methods in updating a knowledge graph of vector embeddings:

    • If I refer to a clustering model where an emotion is represented by a centroid, and the distance (edges) between two words are determined by their cosine similarity distance, then I can probably use this component as a feature in modelling the generated sequence of texts conditioned to emotion states.

    My foot

    1. Assuming I stick with the current plan of constructing the cobwebs. ↩︎
    2. Me. ↩︎
    3. To understand this in application is to consider the example of a chat dialogue where you perform inferences on the dialogue using time-series model approach to distinguish the context labels. ↩︎

    Tom’s progression · Post 5 of 14

    This post sits in Cognition: Social cognition · Identity: Life.

    ← Missing pieces to Naomi Cloning myself into a Language Model →