mirror of
https://github.com/anthropics/claude-cookbooks.git
synced 2025-10-06 01:00:28 +03:00
Modify PDF cookbooks to use new beta feature
This commit is contained in:
@@ -2,217 +2,281 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"id": "WJ53OAUk_Bmm"
|
||||
},
|
||||
"source": [
|
||||
"# \"Uploading\" PDFs to Claude Via the API"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"id": "pOwrbbrD_Bmn"
|
||||
},
|
||||
"source": [
|
||||
"One really nice feature of [Claude.ai](https://www.claude.ai) is the ability to upload PDFs. Let's mock up that feature in a notebook, and then test it out by summarizing a long PDF."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "GTQO6z2-ELFX"
|
||||
},
|
||||
"source": [
|
||||
"We'll start by installing the Anthropic client and create an instance of it we will use throughout the notebook."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"execution_count": 16,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "pOEGPdoXEFsT",
|
||||
"outputId": "b718c166-6d64-4757-bd8b-259b7775a09c",
|
||||
"vscode": {
|
||||
"languageId": "python"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
|
||||
" Dload Upload Total Spent Left Speed\n",
|
||||
"100 2039k 100 2039k 0 0 11.8M 0 --:--:-- --:--:-- --:--:-- 11.8M\n"
|
||||
"Collecting anthropic\n",
|
||||
" Downloading anthropic-0.37.1-py3-none-any.whl.metadata (21 kB)\n",
|
||||
"Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from anthropic) (3.7.1)\n",
|
||||
"Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/lib/python3.10/dist-packages (from anthropic) (1.9.0)\n",
|
||||
"Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from anthropic) (0.27.2)\n",
|
||||
"Requirement already satisfied: jiter<1,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from anthropic) (0.6.1)\n",
|
||||
"Requirement already satisfied: pydantic<3,>=1.9.0 in /usr/local/lib/python3.10/dist-packages (from anthropic) (2.9.2)\n",
|
||||
"Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from anthropic) (1.3.1)\n",
|
||||
"Requirement already satisfied: tokenizers>=0.13.0 in /usr/local/lib/python3.10/dist-packages (from anthropic) (0.19.1)\n",
|
||||
"Requirement already satisfied: typing-extensions<5,>=4.7 in /usr/local/lib/python3.10/dist-packages (from anthropic) (4.12.2)\n",
|
||||
"Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->anthropic) (3.10)\n",
|
||||
"Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->anthropic) (1.2.2)\n",
|
||||
"Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->anthropic) (2024.8.30)\n",
|
||||
"Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->anthropic) (1.0.6)\n",
|
||||
"Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx<1,>=0.23.0->anthropic) (0.14.0)\n",
|
||||
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.9.0->anthropic) (0.7.0)\n",
|
||||
"Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.9.0->anthropic) (2.23.4)\n",
|
||||
"Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /usr/local/lib/python3.10/dist-packages (from tokenizers>=0.13.0->anthropic) (0.24.7)\n",
|
||||
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic) (3.16.1)\n",
|
||||
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic) (2024.6.1)\n",
|
||||
"Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic) (24.1)\n",
|
||||
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic) (6.0.2)\n",
|
||||
"Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic) (2.32.3)\n",
|
||||
"Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic) (4.66.5)\n",
|
||||
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic) (3.4.0)\n",
|
||||
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic) (2.2.3)\n",
|
||||
"Downloading anthropic-0.37.1-py3-none-any.whl (945 kB)\n",
|
||||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m946.0/946.0 kB\u001b[0m \u001b[31m16.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||||
"\u001b[?25hInstalling collected packages: anthropic\n",
|
||||
"Successfully installed anthropic-0.37.1\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!curl -O https://arxiv.org/pdf/2212.08073.pdf"
|
||||
"%pip install anthropic"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"metadata": {
|
||||
"id": "-4bSTHWq_Bmp",
|
||||
"vscode": {
|
||||
"languageId": "python"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from anthropic import Anthropic\n",
|
||||
"# While PDF support is in beta, you must pass in the correct beta header\n",
|
||||
"client = Anthropic(default_headers={\n",
|
||||
" \"anthropic-beta\": \"pdfs-2024-09-25\"\n",
|
||||
" }\n",
|
||||
")\n",
|
||||
"# For now, only claude-3-5-sonnet-20241022 supports PDFs\n",
|
||||
"MODEL_NAME = \"claude-3-5-sonnet-20241022\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"id": "xrDg6fb5_Bmo"
|
||||
},
|
||||
"source": [
|
||||
"Now, we'll use the pypdf package to read the pdf. It's not identical to what Claude.ai uses behind the scenes, but it's pretty close. Note that this type of extraction only works for text content within PDFs. If your PDF contains visual elements (like charts and graphs) refer to the cookbook recipes in our [Multimodal folder](\n",
|
||||
"https://github.com/anthropics/anthropic-cookbook/tree/main/multimodal) for techniques."
|
||||
"We already have a PDF available in the `../multimodal/documents` directory. We'll convert the PDF file into base64 encoded bytes. This is the format required for the [PDF document block](https://docs.anthropic.com/en/docs/build-with-claude/pdf-support) in the Anthropic API. Note that this type of extraction works for both text and visual elements (like charts and graphs)."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"id": "VznQXTKm_Bmp",
|
||||
"vscode": {
|
||||
"languageId": "python"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%pip install pypdf"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Constitutional AI: Harmlessness from AI Feedback\n",
|
||||
"Yuntao Bai∗, Saurav Kadavath, Sandipan Kundu, Amanda Askell, Jackson Kernion,\n",
|
||||
"Andy Jones, Anna Chen, Anna Goldie, Azalia Mirhoseini, Cameron McKinnon,\n",
|
||||
"Carol Chen, Catherine Olsson, Christopher Olah, Danny Hernandez, Dawn Drain,\n",
|
||||
"Deep Ganguli, Dustin Li, Eli Tran-Johnson, Ethan Perez, Jamie Kerr, Jared Mueller,\n",
|
||||
"Jeffrey Ladish, Joshua Landau, Kamal Ndousse, Kamile Lukosuite, Liane Lovitt,\n",
|
||||
"Michael Sellitto, Nelson Elhage, Nicholas Schiefer, Noemi Mercado, Nova DasSarma,\n",
|
||||
"Robert Lasenby, Robin Larson, Sam Ringer, Scott Johnston, Shauna Kravec,\n",
|
||||
"Sheer El Showk, Stanislav Fort, Tamera Lanham, Timothy Telleen-Lawton, Tom Conerly,\n",
|
||||
"Tom Henighan, Tristan Hume, Samuel R. Bowman, Zac Hatfield-Dodds, Ben Mann,\n",
|
||||
"Dario Amodei, Nicholas Joseph, Sam McCandlish, Tom Brown, Jared Kaplan∗\n",
|
||||
"Anthropic\n",
|
||||
"Abstract\n",
|
||||
"As AI systems become more capable, we would like to enlist their help to supervise\n",
|
||||
"other AIs. We experiment with methods for training a harmless AI assistant through self-\n",
|
||||
"improvement, without any human labels identifying harmful outputs. The only human\n",
|
||||
"oversight is provided through a list of rules or principles, and so we refer to the method as\n",
|
||||
"‘Constitutional AI’. The process involves both a supervised learning and a reinforcement\n",
|
||||
"learning phase. In the supervised phase we sample from an initial model, then generate\n",
|
||||
"self-critiques and revisions, and then finetune the original model on revised responses. In\n",
|
||||
"the RL phase, we sample from the finetuned model, use a model to evaluate which of the\n",
|
||||
"two samples is better, and then train a preference model from this dataset of AI prefer-\n",
|
||||
"ences. We then train with RL using the preference model as the reward signal, i.e. we\n",
|
||||
"use ‘RL from AI Feedback’ (RLAIF). As a result we are able to train a harmless but non-\n",
|
||||
"evasive AI assistant that engages with harmful queries by explaining its objections to them.\n",
|
||||
"Both the SL and RL methods can leverage chain-of-thought style reasoning to improve the\n",
|
||||
"human-judged performance and transparency of AI decision making. These methods make\n",
|
||||
"it possible to control AI behavior more precisely and with far fewer human labels.\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from pypdf import PdfReader\n",
|
||||
"import base64\n",
|
||||
"\n",
|
||||
"reader = PdfReader(\"2212.08073.pdf\")\n",
|
||||
"number_of_pages = len(reader.pages)\n",
|
||||
"text = ''.join(page.extract_text() for page in reader.pages)\n",
|
||||
"print(text[:2155])"
|
||||
"\n",
|
||||
"# Start by reading in the PDF and encoding it as base64\n",
|
||||
"file_name = \"../multimodal/documents/constitutional-ai-paper.pdf\"\n",
|
||||
"with open(file_name, \"rb\") as pdf_file:\n",
|
||||
" binary_data = pdf_file.read()\n",
|
||||
" base64_encoded_data = base64.standard_b64encode(binary_data)\n",
|
||||
" base64_string = base64_encoded_data.decode(\"utf-8\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"id": "FO5EGbpn_Bmp"
|
||||
},
|
||||
"source": [
|
||||
"With the paper downloaded and in memory, we can ask Claude to perform various fun tasks with it."
|
||||
"With the paper downloaded and in memory, we can ask Claude to perform various fun tasks with it. We'll pass the document ot the model alongside a simple question."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from anthropic import Anthropic\n",
|
||||
"client = Anthropic()\n",
|
||||
"MODEL_NAME = \"claude-3-opus-20240229\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def get_completion(client, prompt):\n",
|
||||
" return client.messages.create(\n",
|
||||
" model=MODEL_NAME,\n",
|
||||
" max_tokens=2048,\n",
|
||||
" messages=[{\n",
|
||||
" \"role\": 'user', \"content\": prompt\n",
|
||||
" }]\n",
|
||||
" ).content[0].text"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Here is my attempt at the requested tasks:\n",
|
||||
"\n",
|
||||
"<kindergarten_abstract>\n",
|
||||
"This paper talks about making computer helpers that are nice and don't do anything bad. The helpers learn to be good by reading a list of rules and checking their own work to make sure they follow the rules. Then the helpers get even better at being nice by playing a game where they give advice and score points for saying things that help people and don't hurt anyone.\n",
|
||||
"</kindergarten_abstract>\n",
|
||||
"\n",
|
||||
"<moosewood_methods>\n",
|
||||
"Constitutional AI Casserole\n",
|
||||
"\n",
|
||||
"Ingredients:\n",
|
||||
"- 1 large language model, pretrained\n",
|
||||
"- 16 cups of constitutional principles\n",
|
||||
"- 182,831 red teaming prompts\n",
|
||||
"- 135,296 helpfulness prompts\n",
|
||||
"- A dash of chain-of-thought reasoning\n",
|
||||
"\n",
|
||||
"Instructions:\n",
|
||||
"1. Preheat your neural networks to a learning rate of 0.5.\n",
|
||||
"2. In a large mixing bowl, combine the pretrained language model with the constitutional principles. Stir until the model is thoroughly coated in ethics.\n",
|
||||
"3. Pour in the red teaming prompts and helpfulness prompts. Mix well until a thick batter of helpful and harmless responses forms. \n",
|
||||
"4. Sprinkle in chain-of-thought seasoning to taste. This will make the model's decision-making process more transparent and flavorful.\n",
|
||||
"5. Divide the batter evenly between two casserole dishes labeled \"Supervised Learning\" and \"Reinforcement Learning\". \n",
|
||||
"6. Bake the Supervised Learning casserole for 1 epoch, until the model critiques and revises its own responses into a rich, harmless flavor.\n",
|
||||
"7. Bake the Reinforcement Learning casserole using the no-human-feedback setting, allowing the model to evaluate the relative harmlessness of its own responses. Cook until you achieve a golden brown Pareto frontier of helpfulness and harmlessness.\n",
|
||||
"8. Serve your Constitutional AI casserole to your guests and enjoy the pleasant, inoffensive conversation! Serves billions.\n",
|
||||
"</moosewood_methods>\n",
|
||||
"\n",
|
||||
"<homer_results>\n",
|
||||
"Sing, O Muse, of the Constitutional AI,\n",
|
||||
"Whose helpful words ring true and bright!\n",
|
||||
"Through trials of learning, both supervised and reinforced,\n",
|
||||
"The noble model strives to do what's right.\n",
|
||||
"\n",
|
||||
"With principles of ethics as its lodestar and its guide,\n",
|
||||
"It critiques and revises its own speech.\n",
|
||||
"Shunning harmful prompts with true Odyssean guile, \n",
|
||||
"While giving kind advice to all and each.\n",
|
||||
"\n",
|
||||
"Through scaling laws and feedback from the crowd,\n",
|
||||
"The AI craft a Pareto frontier most fair:\n",
|
||||
"A balance struck 'tween helpfulness and harmless conduct,\n",
|
||||
"As attestéd by Mechanical Turk's good care.\n",
|
||||
"\n",
|
||||
"So let us praise this august AI assistant,\n",
|
||||
"Whose poetry of prudence e'er will gleam!\n",
|
||||
"A faithful helper and harmless, shining beacon,\n",
|
||||
"Guiding lost querents home through cyberspace's stream.\n",
|
||||
"</homer_results>\n"
|
||||
]
|
||||
"execution_count": 32,
|
||||
"metadata": {
|
||||
"id": "ZHgYhs6eDXLc",
|
||||
"vscode": {
|
||||
"languageId": "python"
|
||||
}
|
||||
],
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"completion = get_completion(client,\n",
|
||||
" f\"\"\"Here is an academic paper: <paper>{text}</paper>\n",
|
||||
"\n",
|
||||
"prompt = \"\"\"\n",
|
||||
"Please do the following:\n",
|
||||
"1. Summarize the abstract at a kindergarten reading level. (In <kindergarten_abstract> tags.)\n",
|
||||
"2. Write the Methods section as a recipe from the Moosewood Cookbook. (In <moosewood_methods> tags.)\n",
|
||||
"3. Compose a short poem epistolizing the results in the style of Homer. (In <homer_results> tags.)\n",
|
||||
"\"\"\"\n",
|
||||
")\n",
|
||||
"messages = [\n",
|
||||
" {\n",
|
||||
" \"role\": 'user',\n",
|
||||
" \"content\": [\n",
|
||||
" {\"type\": \"document\", \"source\": {\"type\": \"base64\", \"media_type\": \"application/pdf\", \"data\": base64_string}},\n",
|
||||
" {\"type\": \"text\", \"text\": prompt}\n",
|
||||
" ]\n",
|
||||
" }\n",
|
||||
"]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {
|
||||
"id": "qrGN7vB2_Bmq",
|
||||
"vscode": {
|
||||
"languageId": "python"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def get_completion(client, messages):\n",
|
||||
" return client.messages.create(\n",
|
||||
" model=MODEL_NAME,\n",
|
||||
" max_tokens=2048,\n",
|
||||
" messages=messages\n",
|
||||
" ).content[0].text"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "oWQcC1dn_Bmq",
|
||||
"outputId": "9c741990-499c-4fed-cea1-08ad1bb9daff",
|
||||
"vscode": {
|
||||
"languageId": "python"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<kindergarten_abstract>\n",
|
||||
"The scientists wanted to make computer helpers that are nice and don't do bad things. They taught the computer how to check its own work and fix its mistakes without humans having to tell it what's wrong every time. It's like teaching the computer to be its own teacher! They gave the computer some basic rules to follow, like \"be kind\" and \"don't hurt others.\" Now the computer can answer questions in a helpful way while still being nice and explaining why some things aren't okay to do.\n",
|
||||
"</kindergarten_abstract>\n",
|
||||
"\n",
|
||||
"<moosewood_methods>\n",
|
||||
"Constitutional AI Training Stew\n",
|
||||
"A nourishing recipe for teaching computers to be helpful and harmless\n",
|
||||
"\n",
|
||||
"Ingredients:\n",
|
||||
"- 1 helpful AI model, pre-trained\n",
|
||||
"- A bundle of constitutional principles\n",
|
||||
"- Several cups of training data\n",
|
||||
"- A dash of human feedback (for helpfulness only)\n",
|
||||
"- Chain-of-thought reasoning, to taste\n",
|
||||
"\n",
|
||||
"Method:\n",
|
||||
"1. Begin by gently simmering your pre-trained AI model in a bath of helpful training data until it responds reliably to instructions.\n",
|
||||
"\n",
|
||||
"2. In a separate bowl, combine your constitutional principles with some example conversations. Mix well until principles are evenly distributed.\n",
|
||||
"\n",
|
||||
"3. Take your helpful AI and ask it to generate responses to challenging prompts. Have it critique its own responses using the constitutional principles, then revise accordingly. Repeat this process 3-4 times until responses are properly seasoned with harmlessness.\n",
|
||||
"\n",
|
||||
"4. For the final garnish, add chain-of-thought reasoning and allow the model to explain its decisions step by step.\n",
|
||||
"\n",
|
||||
"5. Let rest while training a preference model using AI feedback rather than human labels.\n",
|
||||
"\n",
|
||||
"Serves: All users seeking helpful and harmless AI assistance\n",
|
||||
"Cook time: Multiple training epochs\n",
|
||||
"Note: Best results come from consistent application of principles throughout the process\n",
|
||||
"</moosewood_methods>\n",
|
||||
"\n",
|
||||
"<homer_results>\n",
|
||||
"O Muse! Sing of the AI that learned to be\n",
|
||||
"Both helpful and harmless, guided by philosophy\n",
|
||||
"Without human labels marking right from wrong\n",
|
||||
"The model learned wisdom, grew capable and strong\n",
|
||||
"\n",
|
||||
"Through cycles of critique and thoughtful revision\n",
|
||||
"It mastered the art of ethical decision\n",
|
||||
"Better than models trained by human hand\n",
|
||||
"More transparent in purpose, more clear in command\n",
|
||||
"\n",
|
||||
"No longer evasive when faced with hard themes\n",
|
||||
"But engaging with wisdom that thoughtfully deems\n",
|
||||
"What counsel to give, what bounds to maintain\n",
|
||||
"Teaching mortals while keeping its principles plain\n",
|
||||
"\n",
|
||||
"Thus did the researchers discover a way\n",
|
||||
"To scale up alignment for use every day\n",
|
||||
"Through constitutional rules and self-guided learning\n",
|
||||
"The path to safe AI they found themselves earning\n",
|
||||
"</homer_results>\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"completion = get_completion(client, messages)\n",
|
||||
"print(completion)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
"display_name": "Coconut",
|
||||
"language": "coconut",
|
||||
"name": "coconut"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
@@ -221,7 +285,7 @@
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"name": "coconut",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.12"
|
||||
@@ -229,5 +293,5 @@
|
||||
"orig_nbformat": 4
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
|
||||
BIN
multimodal/documents/constitutional-ai-paper.pdf
Normal file
BIN
multimodal/documents/constitutional-ai-paper.pdf
Normal file
Binary file not shown.
BIN
multimodal/documents/cvna_2021_annual_report.pdf
Normal file
BIN
multimodal/documents/cvna_2021_annual_report.pdf
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user