### Adala Agent Quickstart Example Source: https://github.com/humansignal/adala/blob/master/README.md This snippet shows how to initialize an Adala agent with a static environment, a classification skill, and configure OpenAI chat runtimes for training and inference. It then trains the agent and runs predictions on a test dataset. ```python import os import pandas as pd from adala.agents import Agent from adala.environments import StaticEnvironment from adala.skills import ClassificationSkill from adala.runtimes import OpenAIChatRuntime from rich import print # Train dataset train_df = pd.DataFrame([ ["It was the negative first impressions, and then it started working.", "Positive"], ["Not loud enough and doesn't turn on like it should.", "Negative"], ["I don't know what to say.", "Neutral"], ["Manager was rude, but the most important that mic shows very flat frequency response.", "Positive"], ["The phone doesn't seem to accept anything except CBR mp3s.", "Negative"], ["I tried it before, I bought this device for my son.", "Neutral"], ], columns=["text", "sentiment"]) # Test dataset test_df = pd.DataFrame([ "All three broke within two months of use.", "The device worked for a long time, can't say anything bad.", "Just a random line of text." ], columns=["text"]) agent = Agent( # connect to a dataset environment=StaticEnvironment(df=train_df), # define a skill skills=ClassificationSkill( name='sentiment', instructions="Label text as positive, negative or neutral.", labels=["Positive", "Negative", "Neutral"], input_template="Text: {text}", output_template="Sentiment: {sentiment}" ), # define all the different runtimes your skills may use runtimes = { # You can specify your OpenRouter API Key here or set it ahead of time in your environment variable, OPENROUTER_API_KEY 'openrouter': OpenAIChatRuntime( base_url="https://openrouter.ai/api/v1", model="anthropic/claude-3.5-haiku", api_key=os.getenv("OPENROUTER_API_KEY"), provider="Custom" ), }, default_runtime='openrouter', teacher_runtimes = { "default" : OpenAIChatRuntime( base_url="https://openrouter.ai/api/v1", model="anthropic/claude-3.5-haiku", api_key=os.getenv("OPENROUTER_API_KEY"), provider="Custom" ), } ) print(agent) print(agent.skills) agent.learn(learning_iterations=3, accuracy_threshold=0.95) print('\n=> Run tests ...') predictions = agent.run(test_df) print('\n => Test results:') print(predictions) ``` -------------------------------- ### Adala Quickstart Example Source: https://github.com/humansignal/adala/blob/master/docs/src/index.md This Python code demonstrates how to set up and use an Adala agent for text classification. It includes defining training and testing datasets, configuring an agent with a classification skill and an OpenAI runtime, and then training and testing the agent. ```python import pandas as pd from adala.agents import Agent from adala.environments import StaticEnvironment from adala.skills import ClassificationSkill from adala.runtimes import OpenAIChatRuntime from rich import print # Train dataset train_df = pd.DataFrame([ ["It was the negative first impressions, and then it started working.", "Positive"], ["Not loud enough and doesn't turn on like it should.", "Negative"], ["I don't know what to say.", "Neutral"], ["Manager was rude, but the most important that mic shows very flat frequency response.", "Positive"], ["The phone doesn't seem to accept anything except CBR mp3s.", "Negative"], ["I tried it before, I bought this device for my son.", "Neutral"], ], columns=["text", "sentiment"]) # Test dataset test_df = pd.DataFrame([ "All three broke within two months of use.", "The device worked for a long time, can't say anything bad.", "Just a random line of text." ], columns=["text"]) agent = Agent( # connect to a dataset environment=StaticEnvironment(df=train_df), # define a skill skills=ClassificationSkill( name='sentiment', instructions="Label text as positive, negative or neutral.", labels={'sentiment': ["Positive", "Negative", "Neutral"]}, input_template="Text: {text}", output_template="Sentiment: {sentiment}" ), # define all the different runtimes your skills may use runtimes = { # You can specify your OPENAI API KEY here via `OpenAIRuntime(..., api_key='your-api-key')` 'openai': OpenAIChatRuntime(model='gpt-3.5-turbo'), }, default_runtime='openai', # NOTE! If you have access to GPT-4, you can uncomment the lines bellow for better results # default_teacher_runtime='openai-gpt4', # teacher_runtimes = { # 'openai-gpt4': OpenAIRuntime(model='gpt-4') # } ) print(agent) print(agent.skills) agent.learn(learning_iterations=3, accuracy_threshold=0.95) print('\n=> Run tests ...') predictions = agent.run(test_df) print('\n => Test results:') print(predictions) ``` -------------------------------- ### Adala Quickstart with Pandas and OpenAI Source: https://github.com/humansignal/adala/blob/master/README.md Demonstrates setting up an Adala agent for text classification using pandas DataFrames and the OpenAI GPT-4o model. This example includes data preparation, agent configuration with a classification skill, and running the agent for learning and prediction. ```python import pandas as pd from adala.agents import Agent from adala.environments import StaticEnvironment from adala.skills import ClassificationSkill from adala.runtimes import OpenAIChatRuntime from rich import print # Train dataset train_df = pd.DataFrame([ ["It was the negative first impressions, and then it started working.", "Positive"], ["Not loud enough and doesn't turn on like it should.", "Negative"], ["I don't know what to say.", "Neutral"], ["Manager was rude, but the most important that mic shows very flat frequency response.", "Positive"], ["The phone doesn't seem to accept anything except CBR mp3s.", "Negative"], ["I tried it before, I bought this device for my son.", "Neutral"], ], columns=["text", "sentiment"]) # Test dataset test_df = pd.DataFrame([ "All three broke within two months of use.", "The device worked for a long time, can't say anything bad.", "Just a random line of text." ], columns=["text"]) agent = Agent( # connect to a dataset environment=StaticEnvironment(df=train_df), # define a skill skills=ClassificationSkill( name='sentiment', instructions="Label text as positive, negative or neutral.", labels=["Positive", "Negative", "Neutral"], input_template="Text: {text}", output_template="Sentiment: {sentiment}" ), # define all the different runtimes your skills may use runtimes = { # You can specify your OPENAI API KEY here via `OpenAIRuntime(..., api_key='your-api-key')` 'openai': OpenAIChatRuntime(model='gpt-4o'), }, teacher_runtuntimes = { # You can specify your OPENAI API KEY here via `OpenAIRuntime(..., api_key='your-api-key')` 'default': OpenAIChatRuntime(model='gpt-4o'), }, default_runtime='openai', ) print(agent) print(agent.skills) agent.learn(learning_iterations=3, accuracy_threshold=0.95) print('\n=> Run tests ...') predictions = agent.run(test_df) print('\n => Test results:') print(predictions) ``` -------------------------------- ### Install Adala from GitHub Source: https://github.com/humansignal/adala/blob/master/README.md Install the most up-to-date version of Adala directly from its GitHub repository. ```sh pip install git+https://github.com/HumanSignal/Adala.git ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/humansignal/adala/blob/master/docs/README.md Installs the required Python packages for documentation development using pip. ```bash pip install requirements.txt ``` -------------------------------- ### System Prompt Example Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb An example of a system prompt for a helpful assistant. This sets the initial behavior for the language model. ```text Result:\n"{system}":\nYou are a helpful assistant. ``` -------------------------------- ### Start Kafka and Redis (Native) Source: https://github.com/humansignal/adala/blob/master/server/README.md Use this command to start Kafka and Redis when running the application natively. Ensure you are in the repository root directory. ```bash cd .. docker-compose -f docker-compose.native.yml up ``` -------------------------------- ### Install Development Dependencies with Poetry Source: https://github.com/humansignal/adala/blob/master/CONTRIBUTION.md Use this command to install all necessary dependencies for development, including optional ones. ```bash poetry install --with dev ``` -------------------------------- ### Serve MkDocs Documentation Locally Source: https://github.com/humansignal/adala/blob/master/docs/README.md Starts a local development server with live reloading for MkDocs documentation. ```bash mkdocs serve ``` -------------------------------- ### Start Adala Client (Development) Source: https://github.com/humansignal/adala/blob/master/server/README.md Command to start the client application for development convenience. This is not used in production. ```bash cd ui/ yarn start ``` -------------------------------- ### Example 0: Pizza Pieces Calculation Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb This example demonstrates a correct prediction for a word problem involving percentages and fractions of pizzas. It details the step-by-step calculation process. ```text Q: Ann, Bill, Cate, and Dale each buy personal pan pizzas cut into 4 pieces. If Bill and Dale eat 50% of their pizzas and Ann and Cate eat 75% of the pizzas, how many pizza pieces are left uneaten? A: To solve this problem, we need to first determine the total number of pizza pieces that were bought. Since each person bought a personal pan pizza cut into 4 pieces, we can calculate the total number of pieces by multiplying 4 by the number of people, which is 4. This gives us a total of 16 pizza pieces. Next, we need to calculate how many pieces were eaten by each person. Bill and Dale each ate 50% of their pizzas, which is equivalent to 2 pieces each (50% of 4 pieces is 2 pieces). Ann and Cate each ate 75% of their pizzas, which is equivalent to 3 pieces each (75% of 4 pieces is 3 pieces). To find the total number of pieces eaten, we can add up the pieces eaten by each person: 2 + 2 + 3 + 3 = 10 pieces. Finally, to find the number of pieces left uneaten, we can subtract the total number of pieces eaten from the total number of pieces bought: 16 - 10 = 6 pieces. Therefore, there are 6 pizza pieces left uneaten. ``` -------------------------------- ### Developer Installation of Adala Source: https://github.com/humansignal/adala/blob/master/README.md Set up Adala for development by cloning the repository and installing dependencies using poetry. ```sh git clone https://github.com/HumanSignal/Adala.git cd Adala/ poetry install ``` -------------------------------- ### Example 3: Objective Input Source: https://github.com/humansignal/adala/blob/master/examples/quickstart.ipynb An example of an objective product review and its correct classification. ```text Input: The phone doesn't seem to accept anything except CBR mp3s Output: Objective User feedback: Prediction is correct. ``` -------------------------------- ### Example 0: Subjective Input Source: https://github.com/humansignal/adala/blob/master/examples/quickstart.ipynb An example of a subjective product review and its correct classification. ```text Input: The mic is great. Output: Subjective User feedback: Prediction is correct. ``` -------------------------------- ### Start Adala Server Source: https://github.com/humansignal/adala/blob/master/server/worker_pool/README.md Starts the Adala server for API interactions. Ensure this is running before submitting data. ```bash python -m server.app ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/humansignal/adala/blob/master/CONTRIBUTION.md Build and serve the project's documentation locally using mkdocs. Ensure development dependencies are installed via poetry. ```bash mkdocs serve -f ./docs/mkdocs.yml ``` -------------------------------- ### GSM8k Example 3: Initial Money Calculation Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb This example involves working backward to find an initial amount of money after several spending percentages and a fixed amount are deducted. User feedback indicates the prediction was correct. ```text Q: Abigail spent 60% of her money on food, and 25% of the remainder on her phone bill. After spending $20 on entertainment, she is left with $40. How much money did Abigail have initially? A: Let x be the initial amount of money Abigail had. After spending 60% on food, she is left with 40% of x, which is 0.4x. Out of this 0.4x, she spends 25% on her phone bill, which is 0.25(0.4x) = 0.1x. After spending $20 on entertainment, she is left with 0.4x - 0.1x - $20 = $40. Simplifying, we get 0.3x = $60. Dividing both sides by 0.3, we get x = $200. Therefore, Abigail initially had $200. User feedback: Prediction is correct. ``` -------------------------------- ### Install Label Studio Source: https://github.com/humansignal/adala/blob/master/README.md Install Label Studio, a recommended tool for human-in-the-loop labeling and ground truth dataset production, which Adala supports. ```sh pip install label-studio ``` -------------------------------- ### Learning Agent Prompt and Examples Source: https://github.com/humansignal/adala/blob/master/examples/quickstart.ipynb This snippet shows the initial prompt for the Learning Agent, designed to classify statements as subjective or objective, along with several examples demonstrating its usage and expected outputs. It also includes user feedback on prediction accuracy. ```text Result: "{user}": ## Current prompt "Analyze the provided product review and ascertain whether it predominantly expresses 'Subjective' or 'Objective' statements. Classify it as 'Subjective' if the review primarily discloses personal feelings, emotions, or preferences. However, should the review describe factual details about the product’s functionality or performance, even if these details stem from personal experiences, yet do not assert personal emotions or preferences, classify it as 'Objective'. Keep in mind that a review can draw from personal experiences yet still remain 'Objective' if it imparts information about the product's performance or functionality without declaring personal emotions or preferences." ## Examples ### Example #0 Input: The mic is great. Output: Subjective User feedback: Prediction is correct. ### Example #1 Input: Will order from them again! Output: Subjective User feedback: Prediction is correct. ### Example #2 Input: Not loud enough and doesn't turn on like it should. Output: Subjective User feedback: Prediction is incorrect. Correct answer: "Objective" ### Example #3 Input: The phone doesn't seem to accept anything except CBR mp3s Output: Objective User feedback: Prediction is correct. ### Example #4 Input: All three broke within two months of use. Output: Objective User feedback: Prediction is correct. Summarize your analysis about incorrect predictions and suggest changes to the prompt. ``` -------------------------------- ### Example 1: Subjective Input Source: https://github.com/humansignal/adala/blob/master/examples/quickstart.ipynb Another example of a subjective product review and its correct classification. ```text Input: Will order from them again! Output: Subjective User feedback: Prediction is correct. ``` -------------------------------- ### Example 1: Paintball Cost Calculation Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb This example shows a correct prediction for a word problem involving multiplication to calculate total monthly expenses. It breaks down the calculation into clear steps. ```text Q: John plays paintball 3 times a month. Each time he plays he buys 3 boxes of paintballs. They cost $25 per box. How much does he spend a month on paintballs? A: To determine how much John spends on paintballs in a month, we need to multiply the number of times he plays by the number of boxes he buys each time, and then multiply that by the cost per box. Step 1: Determine the number of boxes John buys in a month. Since John plays paintball 3 times a month and buys 3 boxes each time, we can multiply 3 by 3 to get the total number of boxes he buys in a month: 3 x 3 = 9 boxes. Step 2: Determine the cost of 9 boxes of paintballs. Each box costs $25, so we can multiply 9 by $25 to get the total cost of 9 boxes: 9 x $25 = $225. ``` -------------------------------- ### Install Adala Package Source: https://github.com/humansignal/adala/blob/master/docs/src/index.md Install the Adala library using pip. This command should be run in your terminal or command prompt. ```sh pip install adala ``` -------------------------------- ### Example 4: Objective Input Source: https://github.com/humansignal/adala/blob/master/examples/quickstart.ipynb Another example of an objective product review and its correct classification. ```text Input: All three broke within two months of use. Output: Objective User feedback: Prediction is correct. ``` -------------------------------- ### Start ADALA Server Source: https://github.com/humansignal/adala/blob/master/README.md Starts the ADALA server on a specified port. Use the default port if none is provided. ```sh adala start --port 8090 ``` -------------------------------- ### GSM8k Example 0: Bonus Calculation Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb This example demonstrates a word problem involving calculating hourly wage with a performance bonus, including extra hours. User feedback indicates the prediction was correct. ```text Q: John works a job that offers performance bonuses. He makes $80 a day and works for 8 hours. He has the option of working hard to earn the performance bonus of an extra $20 a day, but the extra effort results in a 2-hour longer workday. How much does John make per hour if he decides to earn the bonus? A: John makes $10 per hour if he decides to earn the bonus. User feedback: Prediction is correct. ``` -------------------------------- ### System Prompt Template Source: https://github.com/humansignal/adala/blob/master/examples/quickstart.ipynb Defines the system's role and initial instructions for the language model. This is the starting point for assistant interactions. ```text Result:\n"{system}":\nYou are a helpful assistant.\n\n ``` -------------------------------- ### Skill Evaluation Example 1 Source: https://github.com/humansignal/adala/blob/master/examples/skillsets_sequence_of_skills.ipynb Shows the output for 'skill_0' with 100.00% accuracy. ```text Skill output to improve: "skill_0" ( Skill = "skill_0" ) Accuracy = 100.00 % ``` -------------------------------- ### Prompt Engineering Workflow - Step 1 Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb Describes the first step in a prompt engineering process where the user provides the current prompt and examples for analysis. ```text Result: "{user}": ## Step 1 I will provide you with the current prompt along with prediction examples. Each example contains the input text, the final prediction produced by the model, and the user feedback. User feedback indicates whether the model prediction is correct or not. Your task is to analyze the examples and user feedback, determining whether the existing instruction is describing the task reflected by these examples precisely, and suggests changes to the prompt to address the incorrect predictions. ``` -------------------------------- ### Skill Evaluation Example 2 Source: https://github.com/humansignal/adala/blob/master/examples/skillsets_sequence_of_skills.ipynb Shows the output for 'skill_1' with 0.00% accuracy, indicating a need for improvement. ```text Skill output to improve: "skill_1" ( Skill = "skill_1" ) Accuracy = 0.00 % ``` -------------------------------- ### Start Adala Application (Native) Source: https://github.com/humansignal/adala/blob/master/server/README.md Command to start the Uvicorn server for the Adala application when running natively. It binds to all network interfaces on port 30001. ```bash poetry run uvicorn app:app --host 0.0.0.0 --port 30001 ``` -------------------------------- ### Progress Bar Example Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb Shows a progress bar indicating task completion, likely during a batch processing or iterative task. ```text Output: 100%|█| 5/5 [00:15<00:00, ``` -------------------------------- ### Progress Output Example Source: https://github.com/humansignal/adala/blob/master/examples/quickstart.ipynb Displays the progress of a task, likely related to data processing or model training, showing completion percentage and rate. ```text Output: 100%|█| 5/5 [00:01<00:00, ``` -------------------------------- ### Classification Example: Furniture/Home Decor (Correct) Source: https://github.com/humansignal/adala/blob/master/examples/classification_skill.ipynb An example of correct classification for a product description falling under the 'Furniture/Home Decor' category. ```text Text: Wooden cream for surfaces. Category: Furniture/Home Decor ``` -------------------------------- ### Start Skill Learning Process Source: https://github.com/humansignal/adala/blob/master/README.md Initiates the learning process for a defined skill. ADALA will use the uploaded data to train the skill. ```sh adala learn --skill "Object Classification" ``` -------------------------------- ### Set OpenAI API Key Source: https://github.com/humansignal/adala/blob/master/README.md Configure your environment to use OpenAI services by exporting your API key. Refer to OpenAI's documentation for key setup instructions. ```sh export OPENAI_API_KEY='your-openai-api-key' ``` -------------------------------- ### GSM8k Example 2: Rattlesnake Calculation Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb This example requires calculating the number of rattlesnakes in a park given the total number of snakes, the count of boa constrictors, and the ratio of pythons to boa constrictors. User feedback indicates the prediction was correct. ```text Q: There are 200 snakes in a park. There are three times as many pythons as boa constrictors. If there 40 boa constrictors and the rest of the snakes are rattlesnakes, calculate the total number of rattlesnakes in the park. A: 200 - 40 = 160 160/4 = 40 There are 40 rattlesnakes in the park. User feedback: Prediction is correct. ``` -------------------------------- ### Prepare Test Data Source: https://github.com/humansignal/adala/blob/master/examples/quickstart.ipynb Create a Pandas DataFrame with text data to be used for testing the agent's skill. This step is crucial for feeding real-world examples into the model. ```python test_df = pd.DataFrame([ "Doesn't hold charge.", "Excellent bluetooth headset", "I love this thing!", "VERY DISAPPOINTED." ], columns=['text']) test_df ``` -------------------------------- ### Add a New Runtime Source: https://github.com/humansignal/adala/blob/master/CONTRIBUTION.md Introduce a new runtime by following the structure of the Runtime abstract class. This example provides a basic structure. ```python ``` -------------------------------- ### Start Adala Server Source: https://github.com/humansignal/adala/blob/master/README.md Initiates the Adala server on the default port 8090. Each agent runs as its own web server. ```sh # Start the Adala server on default port 8090 adala start ``` -------------------------------- ### Assistant's Readiness to Help Source: https://github.com/humansignal/adala/blob/master/examples/quickstart.ipynb Confirms the assistant's willingness to help with prompt engineering tasks. Indicates readiness to receive prompt and examples. ```text Result:\n"{assistant}":\nSure, I’d be happy to help you with this prompt engineering problem. Please provide me with the current prompt and \nthe examples with user feedback.\n\n ``` -------------------------------- ### Start Celery Workers (Native) Source: https://github.com/humansignal/adala/blob/master/server/README.md Initiates Celery workers for stream inference. Navigate to the tasks directory before running this command. ```bash cd tasks/ poetry run celery -A stream_inference worker --loglevel=info ``` -------------------------------- ### Example 2: Celine's Shopping Trip Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb Illustrates the initial step of identifying conditions for a word problem involving purchases and calculating change. ```text ### Example # 1 Q: A shop sells laptops at $ 600 each and a smartphone at $ 400. Celine buys two laptops and four smartphones for her children. How much change does she get back if she has $ 3000? A: Step 1: Identify and understand the relationships and conditions described in the problem. - Celine is buying two laptops and four smartphones for her children. - The laptops cost $ 600 each and the smartphones cost $ 400 each. - Celine has $ 3000 to spend. ``` -------------------------------- ### Analysis of Incorrect Predictions and Prompt Suggestions Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb This section summarizes the analysis of incorrect predictions and suggests changes to the prompt to improve accuracy. It highlights the need for clearer instructions or examples to guide the model's reasoning process. ```text Summarize your analysis about incorrect predictions and suggest changes to the prompt. ``` -------------------------------- ### Build MkDocs Documentation Source: https://github.com/humansignal/adala/blob/master/docs/README.md Builds the static HTML documentation site for deployment. ```bash mkdocs build ``` -------------------------------- ### Classification Example: Footwear/Clothing Source: https://github.com/humansignal/adala/blob/master/examples/classification_skill.ipynb An example of correct classification for a product description falling under the 'Footwear/Clothing' category. ```text Text: Chocolate leather boots. Category: Footwear/Clothing ``` -------------------------------- ### Classification Example: Electronics Source: https://github.com/humansignal/adala/blob/master/examples/classification_skill.ipynb An example of correct classification for a product description falling under the 'Electronics' category. ```text Text: Apple product with a sleek design. Category: Electronics ``` -------------------------------- ### Initialize Adala Client and Submit Batch Source: https://github.com/humansignal/adala/blob/master/server/worker_pool/README.md Demonstrates how to initialize the AdalaClient and submit a batch of data for processing using the client. ```python from label_studio_enterprise.lse_ml_models.adala_client import AdalaClient # Initialize client client = AdalaClient() # Submit batch for processing result = client.submit_worker_pool_batch(model_run, data) ``` -------------------------------- ### Initialize and Run Classification Agent Source: https://github.com/humansignal/adala/blob/master/examples/ontology_creator.ipynb Sets up a classification agent using ClassificationSkill and OpenAI's GPT-4 model, then runs predictions on a test dataset and visualizes the results. ```python from adala.skills import ClassificationSkill predictor = Agent( skills=LinearSkillSet(skills=[ClassificationSkill(labels={'label': labels})]), runtimes={ 'default': OpenAIChatRuntime(model='gpt-4-1106-preview', verbose=False) }) df_test = pd.DataFrame(data=ds['test'][:100]['text'], columns=['text']) pred_test = predictor.run(df_test) pred_test.label.value_counts().plot.pie(figsize=(12, 12)) ``` -------------------------------- ### Create New MkDocs Project Source: https://github.com/humansignal/adala/blob/master/docs/README.md Command to create a new MkDocs project directory. ```bash mkdocs new [dir-name] ``` -------------------------------- ### Classification Example: Beauty/Personal Care Source: https://github.com/humansignal/adala/blob/master/examples/classification_skill.ipynb An example of correct classification for a product description falling under the 'Beauty/Personal Care' category. ```text Text: Natural finish for your lips. Category: Beauty/Personal Care ``` -------------------------------- ### Start Celery Workers Source: https://github.com/humansignal/adala/blob/master/server/worker_pool/README.md Starts Celery workers to process tasks from the 'default' queue. Monitor logs for activity. ```bash celery -A server.celery_app worker --loglevel=info --queues=default ``` -------------------------------- ### Displaying Agent's Learned Instructions Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb This Python snippet prints the current instructions for the agent's math_solver skill, showing the refined prompt after learning. ```python print(agent.skills['math_solver'].instructions) ``` -------------------------------- ### Incorrect Prediction Example Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb This snippet shows an example of an incorrect prediction from a math reasoning model, highlighting the correct answer and the steps to reach it. ```text Prediction is incorrect. Correct answer: "In 7 years, Kaylee will be 5 * 3 = <<5*3=15>>15 years old Let x be the age Kaylee is now. After 7 years, Kaylle will be 15 years old, so x + 7 = 15 x = 15 - 7 x = <<8=8>>8 years old #### 8" ``` -------------------------------- ### Example 2: Subjective Input with Incorrect Prediction Source: https://github.com/humansignal/adala/blob/master/examples/quickstart.ipynb An example where the model incorrectly predicted 'Subjective' for a review that should be 'Objective'. This highlights a potential ambiguity in the prompt. ```text Input: Not loud enough and doesn't turn on like it should. Output: Subjective User feedback: Prediction is incorrect. Correct answer: "Objective" ``` -------------------------------- ### Classification Example: Furniture/Home Decor (Incorrect) Source: https://github.com/humansignal/adala/blob/master/examples/classification_skill.ipynb An example where the initial prompt led to an incorrect classification. The model predicted 'Electronics' instead of 'Furniture/Home Decor'. ```text Text: Laptop stand for the kitchen. Category: Electronics ``` -------------------------------- ### Initialize and Run Summarization Skill Source: https://github.com/humansignal/adala/blob/master/examples/summarization_skill.ipynb Sets up an Adala Agent with the SummarizationSkill and runs it on the prepared DataFrame. The skill processes the 'text' column to generate summaries. ```python from adala.agents import Agent from adala.skills.collection.summarization import SummarizationSkill agent = Agent( skills=SummarizationSkill( name='summarization', input_data_field='text' ) ) agent.run(df) ``` -------------------------------- ### GSM8k Example 4: Hour Difference Calculation Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb This example calculates the difference in hours worked between two pairs of weeks. User feedback indicates the prediction was incorrect, and a detailed breakdown of the correct calculation is provided. ```text Q: Davida worked 35 hours on each of Weeks 1 and 2. She worked 48 hours each of Weeks 3 and 4. How many more hours did Davida work on Weeks 3 and 4 than on Weeks 1 and 2? A: 16 hours User feedback: Prediction is incorrect. Correct answer: "Week 1 + Week 2 = 35 + 35 = 70 hours Week 3 + Week 4 = 48 + 48 = 96 hours Subtract Weeks 3-4 from Weeks 1-2 = 96 - 70 = 26 #### 26" ``` -------------------------------- ### GSM8k Example 1: Annual Insurance Cost Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb This example involves calculating the annual cost of car insurance based on a monthly payment and a percentage of the total cost. User feedback indicates the prediction was correct. ```text Q: Nancy agreed to pay 40% of the cost of her daughter's car insurance, which costs $80 a month. How much will Nancy pay each year? A: Nancy will pay $384 each year for her daughter's car insurance. User feedback: Prediction is correct. ``` -------------------------------- ### User Feedback and Prompt Refinement Guidance Source: https://github.com/humansignal/adala/blob/master/examples/gsm8k_test.ipynb This snippet outlines the guidance for refining a prompt based on user feedback, focusing on precise task description and addressing identified issues. ```text Now please carefully review your reasoning in Step 1: Getting feedback, analyzing and improving ... ## Current prompt ## Follow this guidance to refine the prompt: 1. The new prompt should should describe the task precisely, and address the points raised in the user feedback. 2. The new prompt should be similar to the current instruction, and only differ in the parts that address the issues you identified in Step 1. Example: - Current prompt: "The model should generate a summary of the input text." - New prompt: "The model should generate a summary of the input text. Pay attention to the original style." 3. Reply only with the new prompt. Do not include input and output templates in the prompt. ``` -------------------------------- ### User Prompt and Template Structure Source: https://github.com/humansignal/adala/blob/master/examples/quickstart.ipynb Illustrates how user input and prompts are structured and concatenated to form the final input for the LLM. Shows the template for prompt, input text, and output prediction. ```text Result:\n"{user}":\n\nA prompt is a text paragraph that outlines the expected actions and instructs the large language model (LLM) to \ngenerate a specific output. This prompt is concatenated with the input text, and the model then creates the \nrequired output.\nThis describes the full template how the prompt is concatenated with the input to produce the output:\n\n```\n\n{prompt}\nInput: {text}\nOutput: {prediction}\n```\n\nHere:\n- "Input: {text}" is input template,\n- "{prompt}" is the LLM prompt,\n- "Output: {prediction}" is the output template.\n\nModel can produce erroneous output if a prompt is not well defined. In our collaboration, we’ll work together to \nrefine a prompt. The process consists of two main steps:\n\n## Step 1\nI will provide you with the current prompt along with prediction examples. Each example contains the input text, \nthe final prediction produced by the model, and the user feedback. User feedback indicates whether the model \nprediction is correct or not. Your task is to analyze the examples and user feedback, determining whether the \nexisting instruction is describing the task reflected by these examples precisely, and suggests changes to the \nprompt to address the incorrect predictions.\n\n## Step 2\nNext, you will carefully review your reasoning in step 1, integrate the insights to refine the prompt, and provide \nme with the new prompt that improves the model’s performance.\n\n ``` -------------------------------- ### Display MkDocs Help Message Source: https://github.com/humansignal/adala/blob/master/docs/README.md Prints the help message for MkDocs commands and exits. ```bash mkdocs -h ``` -------------------------------- ### Assistant Response to Prompt Engineering Request Source: https://github.com/humansignal/adala/blob/master/examples/quickstart.ipynb The assistant's confirmation to help with prompt engineering, requesting the current prompt and examples. ```text Result:\n"{assistant}":\nSure, I’d be happy to help you with this prompt engineering problem. Please provide me with the current prompt and \nthe examples with user feedback.\n ```