Tag: agent

  • 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 →

  • Missing pieces to Naomi

    Missing pieces to Naomi

    KEY TERMS

    List of terms mentioned in this post

    • Candidate: the user interacting with Naomi during the interview.
    • Agent: Llama3.1 roleplaying as Naomi.
    • General question/s: questions to be asked during the interview concerning the candidate’s information eg age, occupation etc.
    • Feature question/s: questions or case scenarios mentioned during the interview. The candidate’s responses to these questions are analyzed and used as features in predicting personality predictions and our compatibility score.
    • Response space: responses generated by dummy candidates conditioned to trait patterns aligned with my previous dating history. The intuition behind this idea is that all individuals equip both strengths and weaknesses, and that determining these traits is dependent on the observer’s ability in handling the characteristic combinations i.e. weighing my patience for someone’s flaws against their admirable qualities.

    Overview

    This post is dedicated to Naomi’s unconscious state of acting as a recruitment officer for a dating show (my dating life). Since this was my first attempt at integrating the frontend with the backend, the project turned out messy. The only promising outcome was the realization that I’m not merely a fool of my own words.

    Data Preparation

    This section lists the type of datasets to prepare prior to streaming. The responses were generated by instructing Llama 3.1.

    Feature Questions:

    These questions/case scenarios are based on each dichotomy of MBTI personality traits:

    Response Space:

    Pair of dummy candidate responses and narrations for each feature question.

    Llama 3.1 Prompts:

    Instructions to assist the streaming chatbot and agent helpers during streaming the chatbot.

    Non-manageable problems

    • Decoding parameters: During this trial, the inference API was open-sourced and, unfortunately, wasn’t able to pass decoding parameters.

    • Random Feature questions: A number of feature questions were randomly selected during the chat stream. Hence, even though I prepared questions/case scenarios for each function of the MBTI label, there was no guarantee that a question testing for a specific type of function would be asked during the interview.

    • My information: No form of personal information about myself was passed to the agent. As a result, the agent occasionally generated assumptions about my personal information when requested by the candidates.

    • The way of expressions: Being highly expressive in writing doesn’t necessarily indicate that someone is extremely extroverted. Similarly, a lack of expressiveness in writing might simply suggest that a person struggles with articulating their thoughts rather than being inherently reserved.

      • This problem can be mitigated during the data preparation stage (i.e., the types of questions I’ve prepared for the chatbot). For example, when presented with case scenarios designed to assess the user’s task prioritization behavior, Llama (acting as my custom characters) provides the same procedure for each role-playing candidate. The only difference is in the way the responses are expressed.
    • Limited samples: During the data preparation stage, I only prepared candidate responses tailored toward my dating history instead of actual MBTI labels.

    Manageable problems

    • Agent’s behaviour during live stream:
      • Agent occasionally missed certain questions, mainly the general questions. Despite this, the agent did not skip any feature questions. This suggests that there might be a problem with the data handling methods between Naomi and the candidate during the live stream.

    Improvements

    Below are self-tasked actions that I would like to focus on during my next experiment for Naomi:

    • API: At the time of this experiment, the inference API on Hugging Face was open source. I plan to switch to Ollama during the next experiment.

    • Dataset preparation:

      • Candidate responses should specifically reflect the dichotomy of MBTI types, focusing on Jung’s cognitive functions—Dominant, Auxiliary, Tertiary, and Inferior processes.
      • Feature questions reflect on each of Jung’s cognitive functions.
    • Text summarization: Rather than instructing the agent to narrate the candidate’s response and also speculate on how the candidate might be feeling, I would want to add the following adjustments:

      • The narrations are returned in a fixed format that corresponds with how the candidate’s responses are represented.
      • If possible, the narrations could be rephrased in first-person speech.
    • Adding agent/models helpers to streaming:

      • Predict whether a candidate is being serious or not when completing the interview. The use of this is to allow Naomi to consider returning bad words to the candidate or return responses that reflect on the candidate’s behavior.
    • Predicting the user’s breed: Pick up where I left off. I’ve come to realize that, despite everything, I was still trying to kill two birds with one stone—fitting Naomi into Tom and vice versa. I should probably just complete Naomi on its own at this point.

    • Testing:

      • Replace validation tools with agent helpers, for example:
        • To ensure the dialogue flows smoothly and naturally.
        • To ensure all questions are asked as intended.

    Self-diagnostic on poor data preparation

    During this trial, I wasn’t aware of the different program designs and I was more focused on challenging myself with different OOPs designs in implementing a chatbot. As a result, many of the data classes / handling functions / prepared datasets were not specifically tailored to Naomi’s case, which added problems to this experiment.

    This setup of this model is incomplete due to my impatience part in mishandling the data preparation stage.

    Tom’s progression · Post 4 of 14

    This post sits in Cognition: Social cognition.

    ← Frankenstein Defining a droid's emotional space →