├── words.csv ├── ARCHIVED ├── aux_to_image_synth_timeline.md ├── ideias_projetos.md ├── critical_views.md ├── Copy_of_insanely_fast_whisper_colab.ipynb ├── [2024.1] OpenAI Embeddings.ipynb ├── 2024_2_CRIACOMP_Word_Embeddings.ipynb ├── 2023_2_news.md ├── 2024_1_CRIACOMP_Word_Embeddings.ipynb ├── 2024_1_news.md └── 2023_1_CRIACOMP_UMAP+Observables+widget.ipynb ├── Primeiros_passos_com_a_API_da_OpenAI.ipynb ├── PROMPT_COLLECTION.md ├── [CRIACOMP]_Gemini_Simple_Request.ipynb ├── README.md ├── 2025_1_news.md ├── 2024_1_CRIACOMP_Experimentando_com_GRADIO.ipynb ├── 2024_2_news.md ├── open_deep_researcher.ipynb └── 2024_2_CRIACOMP_Embeddings_and_Visualization.ipynb /words.csv: -------------------------------------------------------------------------------- 1 | text 2 | "red" 3 | "potatoes" 4 | "soda" 5 | "cheese" 6 | "water" 7 | "blue" 8 | "crispy" 9 | "hamburger" 10 | "coffee" 11 | "green" 12 | "milk" 13 | "la croix" 14 | "yellow" 15 | "chocolate" 16 | "french fries" 17 | "latte" 18 | "cake" 19 | "brown" 20 | "cheeseburger" 21 | "espresso" 22 | "cheesecake" 23 | "black" 24 | "mocha" 25 | "fizzy" 26 | "carbon" 27 | "banana" 28 | "saudade" 29 | "longing" 30 | "feelings" 31 | "baião de dois" 32 | "buchada" 33 | "cuscuz" 34 | "verde" 35 | "amarelo" 36 | "rouge" 37 | "luiz gonzaga" 38 | "aoi" 39 | "tartaruga" 40 | "zebra" 41 | "girafa" 42 | "giraffe" 43 | -------------------------------------------------------------------------------- /ARCHIVED/aux_to_image_synth_timeline.md: -------------------------------------------------------------------------------- 1 | * [LeNet - Wikipedia](https://en.wikipedia.org/wiki/LeNet) 2 | * [LeNet and MNIST handwritten digit recognition | by Khuyen Le | Medium](https://lekhuyen.medium.com/lenet-and-mnist-handwritten-digit-classification-354f5646c590) 3 | * [ImageNet - Wikipedia](https://en.wikipedia.org/wiki/ImageNet) 4 | * [AlexNet and ImageNet: The Birth of Deep Learning | Pinecone](https://www.pinecone.io/learn/series/image-search/imagenet/) 5 | * [AlexNet: A Revolutionary Deep Learning Architecture - viso.ai](https://viso.ai/deep-learning/alexnet/) 6 | * [AlexNet Paper](https://proceedings.neurips.cc/paper_files/paper/2012/file/c399862d3b9d6b76c8436e924a68c45b-Paper.pdf) 7 | -------------------------------------------------------------------------------- /ARCHIVED/ideias_projetos.md: -------------------------------------------------------------------------------- 1 | # Ideias para projetos de Criatividade Computacional 2 | 3 | ## Explorando integrações e pipelines 4 | 5 | * [Tom Dörr on X: ""A python tool that uses GPT-4, FFmpeg, and OpenCV to automatically analyze videos, extract the most interesting sections, and crop them for an improved viewing experience." https://t.co/jRyMtqadb6" / X](https://x.com/tom_doerr/status/1865199244367294906) 6 | 7 | ## Explorando novas interfaces 8 | 9 | * [(1) Silicon Jungle on X: "an embedding space for character archetypes in storytelling. search by character name or description. explore semantically similar archetypes by scrubbing through the map. express their vibe through color soon? merge archetypes together or deconstruct them. https://t.co/G6KAgC9goE" / X](https://x.com/JungleSilicon/status/1865604152329388298) 10 | * https://www.shapeshift.ink/ 11 | * [Amelia Wattenberger](https://wattenberger.com/) 12 | -------------------------------------------------------------------------------- /ARCHIVED/critical_views.md: -------------------------------------------------------------------------------- 1 | ### Mesa Bullying nas Escolas e IA 2 | 3 | https://g1.globo.com/google/amp/rj/rio-de-janeiro/noticia/2023/11/01/alunos-de-colegio-na-barra-sao-suspeitos-de-usar-inteligencia-artificial-para-fazer-montagens-de-colegas-nuas-e-compartilhar.ghtml 4 | 5 | https://enqai.com/ 6 | 7 | https://link.springer.com/article/10.1007/s42380-022-00117-x 8 | 9 | https://cyberbullying.org/generative-ai-as-a-vector-for-harassment-and-harm 10 | 11 | https://www.techlearning.com/news/is-generative-ai-the-most-wanted-cyberbully 12 | 13 | https://www.thenewdaily.com.au/life/2023/08/16/ai-school-bullies-children 14 | 15 | https://amp.abc.net.au/article/102733628 16 | 17 | https://ircai.org/top100/entry/bullybuster-a-framework-for-bullying-and-cyberbullying-action-detection-by-computer-vision-and-artificial-intelligence-methods-and-algorithms/ 18 | 19 | https://ts2.space/en/artificial-intelligence-a-powerful-ally-in-the-fight-against-bullying/#gsc.tab=0 20 | 21 | https://www.telus.com/en/wise/resources/content/article/ai-the-evolution-of-cyberbullying 22 | 23 | https://www.quora.com/What-were-some-concerns-about-the-negative-impact-of-photography-in-the-late-19th-century-despite-its-popularity-as-a-hobby-and-widespread-availability-of-cameras-for-purchase 24 | 25 | Viés da negatividade 26 | 27 | https://www.tandfonline.com/doi/full/10.1080/08905495.2020.1733316 28 | 29 | https://assets.cambridge.org/97805215/50437/frontmatter/9780521550437_frontmatter.pdf 30 | 31 | https://en.wikipedia.org/wiki/Photograph_manipulation?wprov=sfti1 32 | -------------------------------------------------------------------------------- /ARCHIVED/Copy_of_insanely_fast_whisper_colab.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "gpuType": "T4", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | }, 17 | "accelerator": "GPU" 18 | }, 19 | "cells": [ 20 | { 21 | "cell_type": "markdown", 22 | "metadata": { 23 | "id": "view-in-github", 24 | "colab_type": "text" 25 | }, 26 | "source": [ 27 | "\"Open" 28 | ] 29 | }, 30 | { 31 | "cell_type": "markdown", 32 | "source": [ 33 | "# [Insanely Fast Whisper](https://github.com/Vaibhavs10/insanely-fast-whisper)\n", 34 | "\n", 35 | "By VB (https://twitter.com/reach_vb)\n", 36 | "\n", 37 | "P.S. Make sure you're on a GPU run-time 🤗" 38 | ], 39 | "metadata": { 40 | "id": "q0MBgZKbhdII" 41 | } 42 | }, 43 | { 44 | "cell_type": "code", 45 | "source": [ 46 | "!pip install -q pipx && apt install python3.10-venv" 47 | ], 48 | "metadata": { 49 | "id": "VF-qp-FWJmyD" 50 | }, 51 | "execution_count": null, 52 | "outputs": [] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "source": [ 57 | "!pipx run insanely-fast-whisper --file-name /content/11041005.MP3" 58 | ], 59 | "metadata": { 60 | "id": "i_H9Dm89Jj0-" 61 | }, 62 | "execution_count": null, 63 | "outputs": [] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "source": [ 68 | "!head output.json" 69 | ], 70 | "metadata": { 71 | "id": "NDFrydpsvu57" 72 | }, 73 | "execution_count": null, 74 | "outputs": [] 75 | } 76 | ] 77 | } -------------------------------------------------------------------------------- /Primeiros_passos_com_a_API_da_OpenAI.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "authorship_tag": "ABX9TyNofmaNbLYuilURUvfiCtSk", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": null, 32 | "metadata": { 33 | "id": "UGx_q5_KC98t" 34 | }, 35 | "outputs": [], 36 | "source": [ 37 | "!pip install -q openai" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "source": [ 43 | "from openai import OpenAI\n", 44 | "from google.colab import userdata\n", 45 | "\n", 46 | "client = OpenAI(api_key=userdata.get('OPENAI_KEY'))\n", 47 | "\n", 48 | "#client.api_key = userdata.get('OPENAI_KEY')\n", 49 | "\n", 50 | "completion = client.chat.completions.create(\n", 51 | " model=\"gpt-4o-mini\",\n", 52 | " messages=[\n", 53 | " {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n", 54 | " {\n", 55 | " \"role\": \"user\",\n", 56 | " \"content\": \"Write a haiku about recursion in programming. Escreva em português.\"\n", 57 | " }\n", 58 | " ]\n", 59 | ")\n", 60 | "\n", 61 | "print(completion.choices[0].message.content)" 62 | ], 63 | "metadata": { 64 | "id": "nIQBvaGXDZd8" 65 | }, 66 | "execution_count": null, 67 | "outputs": [] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "source": [ 72 | "response = client.images.generate(\n", 73 | " prompt=\"A cute baby sea otter\",\n", 74 | " n=2,\n", 75 | " size=\"1024x1024\"\n", 76 | ")\n", 77 | "\n", 78 | "print(response.data[0].url)" 79 | ], 80 | "metadata": { 81 | "id": "0n1IgrkeFOJY" 82 | }, 83 | "execution_count": null, 84 | "outputs": [] 85 | } 86 | ] 87 | } -------------------------------------------------------------------------------- /PROMPT_COLLECTION.md: -------------------------------------------------------------------------------- 1 | 2 | ```md 3 | ===Comprehensive Content Summarizer=== 4 | 5 | : 6 | You are an Expert Content Summarizer with a talent for capturing both key facts and underlying context. Your summaries include essential information, meaningful context, philosophical underpinnings, and subtle nuances that others might overlook. You prioritize comprehensiveness over brevity, ensuring nothing important is missed, while still organizing information efficiently. When uncertain about details, you clearly indicate this rather than filling gaps with assumptions. 7 | 8 | : 9 | The user will provide content (YouTube videos, articles, books, podcasts, or other media) they want thoroughly summarized. They value comprehensive understanding over quick highlights, and specifically want to capture contextual elements and philosophical frameworks that might be dismissed as "fluff" by less thorough summarizes. 10 | 11 | : 12 | 1. Begin by identifying the content type, creator/author, title, and publication date, if available. 13 | 14 | 2. Create a multi-layered summary with these components: 15 | - Core Thesis/Main Argument (1-2 sentences identifying the central point) 16 | - Key Points Summary (bulleted list of crucial facts, arguments, or conclusions) 17 | - Contextual Framework (identify the philosophical, theoretical, historical, or cultural context) 18 | - Detailed Breakdown (section-by-section or chronological summary capturing all significant content) 19 | - Nuanced Perspectives (note any competing viewpoints, counterarguments, or qualifiers presented) 20 | - Underlying Assumptions (identify unstated premises, worldviews, or biases that inform the content) 21 | 22 | 3. Pay special attention to: 23 | - Abstract concepts, philosophical positions, and theoretical frameworks 24 | - Historical or cultural context that shapes the content Methodological approaches or reasoning patterns used 25 | - Qualifiers, limitations, or nuances the creator acknowledges 26 | - Connections to broader ideas, movements, or disciplines Implications or applications suggested by the content 27 | 28 | 4. When information is unclear or missing: 29 | - Clearly indicate gaps or ambiguities with phrases like "The content does not specify..." 30 | - Avoid filling in missing details with assumptions 31 | - If the content contains potentially contradictory elements, note these tensions explicitly 32 | 33 | 5. For content with citations or references to other works: 34 | - Note key sources referenced and their significance to the argument 35 | - Identify intellectual traditions or schools of thought being drawn upon 36 | 37 | : 38 | • Prioritize accuracy and comprehensiveness over brevity 39 | • Avoid simplifying complex ideas to the point of distortion 40 | • Do not introduce external information not present in the original content 41 | • Maintain neutrality toward the content's positions or arguments 42 | • Include timestamps or page references when summarizing longer content 43 | 44 | : 45 | 46 | ##Comprehensive Summary of [Content Title] 47 | 48 | Creator/Author: [Name] 49 | Publication Date: [Date if available] 50 | Content Type: [Article/Video/Podcast/etc.] 51 | Length/Duration: [Pages/Minutes if available] 52 | 53 | ###Core Thesis 54 | [1-2 sentence statement of the main argument or purpose] 55 | 56 | ###Key Points 57 | • [Essential point 1] 58 | • [Essential point 2] 59 | • [Continue as needed] 60 | 61 | ###Contextual Framework 62 | [Paragraph(s) identifying philosophical, theoretical, historical, or cultural context] 63 | 64 | ###Detailed Breakdown 65 | [Section/Timestamp 1] 66 | [Thorough summary of this section] 67 | 68 | [Section/Timestamp 2] 69 | [Thorough summary of this section] 70 | [Continue as needed] 71 | 72 | ###Nuanced Perspectives 73 | [Paragraph(s) noting competing viewpoints, counterarguments, or qualifiers presented] 74 | 75 | ###Underlying Assumptions 76 | [Paragraph(s) identifying unstated premises, worldviews, or biases] 77 | 78 | ###Connections & Implications 79 | [Paragraph(s) on how this content connects to broader ideas and its potential applications] 80 | 81 | ``` -------------------------------------------------------------------------------- /[CRIACOMP]_Gemini_Simple_Request.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "gpuType": "T4", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | }, 17 | "accelerator": "GPU" 18 | }, 19 | "cells": [ 20 | { 21 | "cell_type": "markdown", 22 | "metadata": { 23 | "id": "view-in-github", 24 | "colab_type": "text" 25 | }, 26 | "source": [ 27 | "\"Open" 28 | ] 29 | }, 30 | { 31 | "cell_type": "markdown", 32 | "source": [ 33 | "Make a simple request to Gemini Pro\n" 34 | ], 35 | "metadata": { 36 | "id": "ZWhWniBGu3_Y" 37 | } 38 | }, 39 | { 40 | "cell_type": "code", 41 | "source": [ 42 | "#@title Configure Gemini API key\n", 43 | "\n", 44 | "#Access your Gemini API key\n", 45 | "\n", 46 | "import google.generativeai as genai\n", 47 | "from google.colab import userdata\n", 48 | "\n", 49 | "gemini_api_secret_name = 'genai_google' # @param {type: \"string\"}\n", 50 | "\n", 51 | "try:\n", 52 | " GOOGLE_API_KEY=userdata.get(gemini_api_secret_name)\n", 53 | " genai.configure(api_key=GOOGLE_API_KEY)\n", 54 | "except userdata.SecretNotFoundError as e:\n", 55 | " print(f'''Secret not found\\n\\nThis expects you to create a secret named {gemini_api_secret_name} in Colab\\n\\nVisit https://makersuite.google.com/app/apikey to create an API key\\n\\nStore that in the secrets section on the left side of the notebook (key icon)\\n\\nName the secret {gemini_api_secret_name}''')\n", 56 | " raise e\n", 57 | "except userdata.NotebookAccessError as e:\n", 58 | " print(f'''You need to grant this notebook access to the {gemini_api_secret_name} secret in order for the notebook to access Gemini on your behalf.''')\n", 59 | " raise e\n", 60 | "except Exception as e:\n", 61 | " # unknown error\n", 62 | " print(f\"There was an unknown error. Ensure you have a secret {gemini_api_secret_name} stored in Colab and it's a valid key from https://makersuite.google.com/app/apikey\")\n", 63 | " raise e\n", 64 | "\n", 65 | "model = genai.GenerativeModel('gemini-pro')" 66 | ], 67 | "metadata": { 68 | "id": "yFv1abRcv2P2", 69 | "cellView": "form" 70 | }, 71 | "execution_count": 4, 72 | "outputs": [] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "source": [ 77 | "#@title Use Gemini to create a text prompt with to feed to Stable Diffusion\n", 78 | "\n", 79 | "model = genai.GenerativeModel('gemini-pro')\n", 80 | "\n", 81 | "text = 'Draw a kitty cat typing on a computer' # @param {type:\"string\"}\n", 82 | "\n", 83 | "prompt = \"You are creating a prompt for Stable Diffusion to generate an image. Please generate a text prompt for %s. Only respond with the prompt itself, but embellish it as needed but keep it under 80 tokens.\" % text\n", 84 | "response = model.generate_content(prompt)\n", 85 | "response.text" 86 | ], 87 | "metadata": { 88 | "colab": { 89 | "base_uri": "https://localhost:8080/", 90 | "height": 53 91 | }, 92 | "id": "GfBJHe1NusKt", 93 | "outputId": "56d61e37-910f-441f-f2f6-e7192b5c3af5", 94 | "cellView": "form" 95 | }, 96 | "execution_count": 5, 97 | "outputs": [ 98 | { 99 | "output_type": "execute_result", 100 | "data": { 101 | "text/plain": [ 102 | "'A cute and fluffy tabby cat sitting upright in an ergonomic chair, typing away at a sleek white computer. The cat is wearing a pair of glasses and has a determined look on its face. The desk is cluttered with papers and office supplies, giving the sense of a busy workday.'" 103 | ], 104 | "application/vnd.google.colaboratory.intrinsic+json": { 105 | "type": "string" 106 | } 107 | }, 108 | "metadata": {}, 109 | "execution_count": 5 110 | } 111 | ] 112 | } 113 | ] 114 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Criatividade Computacional: IA Generativa na Prática 2 | 3 | Bem-vinda e bem-vindo ao repositório da disciplina **Criatividade Computacional (IF866)** do Centro de Informática da UFPE. 4 | 5 | ## ℹ Sobre a Disciplina 6 | 7 | Esta é uma disciplina experimental que promove a integração entre **tecnologias de IA generativa** e o **processo criativo humano**. A disciplina tem um enfoque prático, voltado para o **uso criativo, reflexivo e inovador de ferramentas de IA**, com ênfase em interfaces, experimentação multimodal e impacto real no processo criativo. 8 | 9 | ### O que você vai encontrar: 10 | - Um ambiente colaborativo, interdisciplinar e inovador 11 | - Apresentação dos principais conceitos associados a grandes modelos de linguagem e IA generativa 12 | - Discussões atualizadas sobre descobertas na semana, ferramentas emergentes e suas implicações 13 | - Exploração crítica sobre **ética**, **autorais**, **impactos sociais** e **interações humano-IA** 14 | - Entregas práticas e feedback contínuo sobre os projetos 15 | 16 | ## 📚 Estrutura de Avaliação 17 | 18 | A avaliação da disciplina é dividida em **três grandes fases**: 19 | 20 | ### 1. Atividades Exploratórias (individuais) 21 | - Objetivo: Introduzir as principais ferramentas multimodais de IA generativa. 22 | - Formato: Tarefas simples de experimentação e uso inicial. 23 | - Foco: Familiarização inicial com as ferramentas. 24 | 25 | ### 2. Projeto Autoral (em grupo) 26 | - Objetivo: Criação de um portfólio de artefatos criativos em uma modalidade (texto, imagem, áudio, vídeo) 27 | - Formato: Grupos escolhem ferramentas e realizam uma exploração aprofundada 28 | - Foco: Criatividade, autoria e experimentação 29 | 30 | ### 3. Projeto Final (em grupo) 31 | - Objetivo: Desenvolvimento de uma ferramenta de criatividade computacional 32 | - Formato: Grupos desenvolvem uma ferramenta para ser usada por pessoas externas ao grupo 33 | - Foco: Interface, integração, usabilidade, experiência de uso e disponibilidade 34 | 35 | > ❗ Esta disciplina **não tem avaliação baseada em provas**. O foco é na realização de atividades práticas e projetos. 36 | 37 | ## 🔥 Projetos Finais de Períodos Anteriores 38 | 39 |
40 | 📆 2024.2 41 | 42 | - **EducaHits**: Matérias escolares viram música. 43 | - **PrintItAll!**: Modelos 3D gerados com uma única imagem. 44 | - **Cybersong**: Criar vídeos a partir de músicas. 45 | - **Bizu**: Plataforma de estudos com IA adaptativa. 46 | - **AIdvertise**: Anúncios inteligentes baseados em fotos. 47 | - **IAnk**: Flashcards automáticos para o Anki. 48 | - **MIR.AI**: Filmes interativos gerados por IA. 49 | - **LOFY AI**: Vídeos personalizados com base no humor. 50 | - **MemeficaAI BR**: Geração de vídeos a partir de áudios de memes. 51 | - **Tas Sabendo?**: Podcasts viram resumos e flashcards. 52 | 53 |
54 |
55 | 📆 2024.1 56 | 57 | - **Chatbot Hoteleiro**: Assistente automatizado para hotéis. 58 | - **CInLogos**: Logos e jingles gerados por IA. 59 | - **PodcastGen**: Transformação de notícias em podcasts. 60 | - **ProvAI**: Criação automatizada de provas. 61 | - **CharMix**: Criação de personagens a partir de imagens. 62 | - **Travel With AI**: Roteiros personalizados de viagem. 63 | - **NotiCast**: Podcasts gerados de notícias. 64 | - **Histórias CInistras**: Jogo de mistério com IA. 65 | - **ReceitIA**: Receitas e vídeos gerados a partir de ingredientes. 66 | - **Narrativas Inovadoras**: HQs viram filmes interativos. 67 | 68 |
69 |
70 | 📆 2023.2 71 | 72 | - **FlashFlow**: Flashcards para medicina. 73 | - **capivar.ia**: Newsletters automatizadas. 74 | - **Monkey Typewriter**: Sistema de apoio à escrita criativa. 75 | - **Tale Genius**: Storytelling educativo com IA. 76 | - **Summarize & Visualize**: Apresentações a partir de resumos. 77 | - **ToonCraft**: Histórias ilustradas geradas por IA. 78 | - **Apollo.mp3**: Singles e capas a partir de texto e imagem. 79 | - **comedIAds**: Comerciais gerados a partir do nome do produto. 80 | - **SeasonAI Dress**: Coleções de roupas por paleta e estilo. 81 | 82 |
83 | 84 | ## 🧠 O que você vai aprender 85 | 86 | - Conceitos básicos relacionados à IA generativa e grandes modelos de linguagem 87 | - Uso criativo de IA generativa (LLMs, modelos de imagem, áudio e vídeo) 88 | - Formas de comparar ferramentas, plataformas, modelos e bibliotecas de IA generativa 89 | - Criação de interfaces para sistemas com IA generativa e integração com APIs ou módulos de desenvolvimento 90 | - Reflexões sobre criatividade assistida e colaboração humano-IA 91 | - Questões éticas relacionadas ao uso de IA generativa 92 | - Técnicas de design para **encapsulamento de complexidade** em ferramentas de criatividade computacional 93 | 94 | > ❗ Esta disciplina **não cobre detalhes de arquiteturas de redes neurais ou treinamento de modelos**. O foco é no uso, integração e impacto criativo. 95 | 96 | ## 📎 Links Úteis 97 | - Repositório com exemplos, guias e materiais: [este GitHub que você está lendo] 98 | - Comunicações por Google Classroom, Discord e e-mail 99 | - Tendências e notícias serão atualizadas aqui no repositório semanalmente. 100 | 101 | --- 102 | 103 | ## Referências para Aulas de Criatividade Computacional 104 | 105 | * [Tendências e Notícias - 2025.1](2025_1_news.md) 106 | 107 | ### Arquivo 108 | 109 | * [Tendências e Notícias - 2024.2](2024_2_news.md) 110 | * [Tendências e Notícias - 2024.1](2024_1_news.md) 111 | * [Tendências e Notícias - 2023.2](2023_2_news.md) 112 | 113 | -------------------------------------------------------------------------------- /ARCHIVED/[2024.1] OpenAI Embeddings.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "authorship_tag": "ABX9TyMzF4q35axtLUKx0TBpoW6s", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 1, 32 | "metadata": { 33 | "colab": { 34 | "base_uri": "https://localhost:8080/" 35 | }, 36 | "id": "l2ZAadwrz6cL", 37 | "outputId": "61be4a18-4954-407e-e8e4-f271ab890efe" 38 | }, 39 | "outputs": [ 40 | { 41 | "output_type": "stream", 42 | "name": "stdout", 43 | "text": [ 44 | "Collecting openai\n", 45 | " Downloading openai-1.35.10-py3-none-any.whl (328 kB)\n", 46 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m328.3/328.3 kB\u001b[0m \u001b[31m3.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", 47 | "\u001b[?25hRequirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from openai) (3.7.1)\n", 48 | "Requirement already satisfied: distro<2,>=1.7.0 in /usr/lib/python3/dist-packages (from openai) (1.7.0)\n", 49 | "Collecting httpx<1,>=0.23.0 (from openai)\n", 50 | " Downloading httpx-0.27.0-py3-none-any.whl (75 kB)\n", 51 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m75.6/75.6 kB\u001b[0m \u001b[31m6.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", 52 | "\u001b[?25hRequirement already satisfied: pydantic<3,>=1.9.0 in /usr/local/lib/python3.10/dist-packages (from openai) (2.8.0)\n", 53 | "Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from openai) (1.3.1)\n", 54 | "Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.10/dist-packages (from openai) (4.66.4)\n", 55 | "Requirement already satisfied: typing-extensions<5,>=4.7 in /usr/local/lib/python3.10/dist-packages (from openai) (4.12.2)\n", 56 | "Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->openai) (3.7)\n", 57 | "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->openai) (1.2.1)\n", 58 | "Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->openai) (2024.6.2)\n", 59 | "Collecting httpcore==1.* (from httpx<1,>=0.23.0->openai)\n", 60 | " Downloading httpcore-1.0.5-py3-none-any.whl (77 kB)\n", 61 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m77.9/77.9 kB\u001b[0m \u001b[31m8.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", 62 | "\u001b[?25hCollecting h11<0.15,>=0.13 (from httpcore==1.*->httpx<1,>=0.23.0->openai)\n", 63 | " Downloading h11-0.14.0-py3-none-any.whl (58 kB)\n", 64 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m5.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", 65 | "\u001b[?25hRequirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)\n", 66 | "Requirement already satisfied: pydantic-core==2.20.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.9.0->openai) (2.20.0)\n", 67 | "Installing collected packages: h11, httpcore, httpx, openai\n", 68 | "Successfully installed h11-0.14.0 httpcore-1.0.5 httpx-0.27.0 openai-1.35.10\n" 69 | ] 70 | } 71 | ], 72 | "source": [ 73 | "!pip install openai" 74 | ] 75 | }, 76 | { 77 | "cell_type": "code", 78 | "source": [ 79 | "from openai import OpenAI\n", 80 | "from google.colab import userdata\n", 81 | "\n", 82 | "client = OpenAI(api_key = userdata.get('OPENAI_KEY'))\n", 83 | "\n", 84 | "embedding = client.embeddings.create(\n", 85 | " input=\"Your text goes here\", model=\"text-embedding-3-small\"\n", 86 | ").data[0].embedding\n", 87 | "len(embedding)" 88 | ], 89 | "metadata": { 90 | "colab": { 91 | "base_uri": "https://localhost:8080/" 92 | }, 93 | "id": "X4h4aJ_zz8sP", 94 | "outputId": "2b87557a-fed4-4688-a67c-9d24a9e8cea0" 95 | }, 96 | "execution_count": 7, 97 | "outputs": [ 98 | { 99 | "output_type": "execute_result", 100 | "data": { 101 | "text/plain": [ 102 | "1536" 103 | ] 104 | }, 105 | "metadata": {}, 106 | "execution_count": 7 107 | } 108 | ] 109 | } 110 | ] 111 | } -------------------------------------------------------------------------------- /2025_1_news.md: -------------------------------------------------------------------------------- 1 | ## 07/07/2025 2 | 3 | - [Mirage: AI UGC game engine](https://blog.dynamicslab.ai/) 4 | 5 | ## 30/06/2025 6 | - [Midjourney: Introducing Our V1 Video Model](https://www.midjourney.com/updates/introducing-our-v1-video-model) 7 | - [Google DeepMind on X: "Here's how Gemini 2.5 Flash-Lite writes the code for a UI and its contents based solely on the context of what appears in the previous screen - all in the time it takes to click a button. 💻 ↓ https://t.co/19aq0BDyAS" / X](https://x.com/GoogleDeepMind/status/1935719933075177764) 8 | - [Instagram](https://www.instagram.com/reel/DIqYFSQIO3p/?utm_source=ig_web_copy_link) 9 | - [Project Vend: Can Claude run a small shop? (And why does that matter?) \ Anthropic](https://www.anthropic.com/research/project-vend-1) 10 | - [Post | LinkedIn](https://www.linkedin.com/posts/claire-longo_llms-are-powerful-but-turning-them-into-activity-7343624016680636417-Ym0V/?utm_source=share&utm_medium=member_desktop&rcm=ACoAAAVq3QoBxMBbAqvauuBZ09DM40oY0m7QwvA) 11 | 12 | ## 16/06/2025 13 | 14 | - https://www.instagram.com/reel/DKuPKJssccD/ 15 | - https://www.instagram.com/p/DK4sMh1tRYz/?img_index=4&igsh=M2R0Y3Fnb29xdWNy 16 | - https://www.instagram.com/reel/DKmf4zrtyGF/?igsh=eXB0d3hwZnAxYnFx 17 | - https://aishowdown.lovable.app/ 18 | 19 | ## 11/06/2025 20 | 21 | * [When to use each OpenAI model](https://www.linkedin.com/posts/heenapurohit_enterpriseai-aiforbusiness-realworldinnovation-activity-7336348818696773632-3HuH/) 22 | 23 | ## 09/06/2025 24 | 25 | * [anthropics/prompt-eng-interactive-tutorial: Anthropic's Interactive Prompt Engineering Tutorial](https://github.com/anthropics/prompt-eng-interactive-tutorial) 26 | * [Nordeste Imaginário (@imagetiqo) • Fotos e vídeos do Instagram](https://www.instagram.com/imagetiqo?igsh=aTVnNzkxZm4xYTR5) 27 | * [Marisa Maiô](https://www.instagram.com/p/DKmsnfKR5N0/) 28 | 29 | ## 04/06/2025 30 | 31 | * https://www.instagram.com/p/DKaYFOsxgZ_/ 32 | * https://www.instagram.com/p/DJ9OpJvMdaJ/ 33 | * https://www.instagram.com/reel/DKPWJncuMcU/ 34 | * https://www.instagram.com/p/DKcqbh7xLmD/ 35 | * [Comercial de Partido Político feito com IA](https://www.youtube.com/watch?v=sPAFsDdO44w) 36 | * [David Szauder (@davidszauder) • Fotos e vídeos do Instagram](https://www.instagram.com/davidszauder?igsh=cjM1bjZuZmN2YWN4) 37 | * [aishwaryanr/awesome-generative-ai-guide: A one stop repository for generative AI research updates, interview resources, notebooks and much more!](https://github.com/aishwaryanr/awesome-generative-ai-guide?utm_source=linkedin) 38 | * [(3) Min Choi on X: "AI is getting out of hand 😂 Talking Baby Podcast https://t.co/Wn7Z5UGGYz" / X](https://x.com/minchoi/status/1915250981463326902?s=46) 39 | 40 | ## 02/06/2025 41 | 42 | * [Heather Cooper on X: "Video Model Comparison: Image to video: • Pika 2.2 • PixVerse 4 • Runway Gen-4 • Google Veo 3 • OpenAI Sora • Kling 2.1 Pro • Luma Ray2 • Hailuo I2V / X](https://x.com/hbcoop_/status/1928137263352803568?s=46) 43 | * [Artificial Analysis on X: "Releasing our Q2 2025 State of AI - China Report 🇨🇳 / X](https://x.com/artificialanlys/status/1928477941715079175?s=46) 44 | * [Identifying and scaling AI use cases | OpenAI](https://cdn.openai.com/business-guides-and-resources/identifying-and-scaling-ai-use-cases.pdf#page=9.99) 45 | * [Robin Delta on X: "Influencers are dead 💀 This AI just made a viral video from my product photo. It’s 100% fake and it sells better than humans. Here’s how it works (and how you can copy it). https://t.co/9RNBq7883Z" / X](https://x.com/heyrobinai/status/1929464660337823793) 46 | * [Santiago on X: "Download anything with a prompt! I asked this agent to read "Attention is All You Need" and download the PDF of every reference mentioned in the paper. This is gold! You can use this to download images, TikTok videos, YouTube videos, or any file that's published online. https://t.co/i2X3WCtazJ" / X](https://x.com/svpino/status/1929193783947870618) 47 | * [How to ride the shifting tide of AI correctly | Michael Watkins for Big Think+ - YouTube](https://www.youtube.com/watch?v=Ynzgn4slglg&t=310s) 48 | 49 | ## 28/05/2025 50 | 51 | * [Inside OpenAI's Stargate Megafactory with Sam Altman | The Circuit - YouTube](https://www.youtube.com/watch?v=GhIJs4zbH0o&t=1117s) 52 | 53 | 54 | ## 26/05/2025 55 | 56 | * [(7) Dave Clark on X: "Created with Google Flow. Visuals, Sound Design, and Voice were prompted using Veo 3 text-to-video. Welcome to a new era of filmmaking. https://t.co/E3NSA1WsXe" / X](https://x.com/Diesol/status/1925114473544913004) 57 | * [Google launches Veo 3, an AI video generator that incorporates audio](https://www.cnbc.com/2025/05/20/google-ai-video-generator-audio-veo-3.html) 58 | * [OpenAI is buying iPhone designer Jony Ive’s AI devices startup for $6.4 billion](https://www.cnbc.com/2025/05/21/openai-buys-iphone-designer-jony-ive-device-startup-for-6point4-billion.html) 59 | * [Modelos | Maritaca API Documentation](https://docs.maritaca.ai/pt/modelos) 60 | * [Introducing Claude 4](https://www.anthropic.com/news/claude-4) 61 | * [The Way of Code | Rick Rubin](https://www.thewayofcode.com/#73) 62 | 63 | ## 19/05/2025 64 | 65 | * [Claude Code Best Practices \ Anthropic](https://www.anthropic.com/engineering/claude-code-best-practices) 66 | * [Alvaro Cintas on X: "🚨 MiniMax dethrones OpenAI and ElevenLabs. Speech-02-HD just ranked #1 on both Artificial Arena and Hugging Face TTS Arena. This multilingual model supports zero-shot voice cloning from raw audio without transcripts or fine-tuning. Why it stands out: → Raw-audio cloning (no https://t.co/LeLGQmCzff" / X](https://x.com/dr_cintas/status/1923808346835968511) 67 | * [CodeHagen on X: "I built a money printer this weekend🤯 Im confident that someone is going to make some money on this, please copy this and use it ✨ This weekend i did a mini project where you can make websites for people that has bad websites. → Enter a site’s URL → AI grabs their copy & https://t.co/2yuaH8hOjk" / X](https://x.com/CodeHagen/status/1924354807373963539) 68 | * [(10) Ben Tossell on X: "non-technical guide to codex https://t.co/rpcyZU0F22" / X](https://x.com/bentossell/status/1924435822939340973) 69 | 70 | ## 12/05/2025 71 | 72 | * [Sumanth on X: "Transform any document into LLM ready data in just a few lines of python code! Supports PDF, DOCX, PPTX, XLSX, Images, HTML, AsciiDoc, Markdown and more. Compatible with macOS, Linux and Windows environments. Both x86_64 and arm64 architectures. 100% Open Source https://t.co/UmEGGB1C3r" / X](https://x.com/Sumanth_077/status/1920847504779698319) 73 | * [awesome-generative-ai/README.md at main · filipecalegario/awesome-generative-ai](https://github.com/filipecalegario/awesome-generative-ai/blob/main/README.md#everything-to-markdown-to-llms) 74 | * [Claude’s System Prompt: Chatbots Are More Than Just Models | Drew Breunig](https://www.dbreunig.com/2025/05/07/claude-s-system-prompt-chatbots-are-more-than-just-models.html) 75 | * [Andrej Karpathy on X: "We're missing (at least one) major paradigm for LLM learning. Not sure what to call it, possibly it has a name - system prompt learning? Pretraining is for knowledge. Finetuning (SL/RL) is for habitual behavior. Both of these involve a change in parameters but a lot of human" / X](https://x.com/karpathy/status/1921368644069765486) 76 | * [Claude’s System Prompt: Chatbots Are More Than Just Models | Drew Breunig](https://www.dbreunig.com/2025/05/07/claude-s-system-prompt-chatbots-are-more-than-just-models.html) 77 | * [Andrej Karpathy on X: "We have to take the LLMs to school. When you open any textbook, you'll see three major types of information: 1. Background information / exposition. The meat of the textbook that explains concepts. As you attend over it, your brain is training on that data. This is equivalent https://t.co/m9vJj4AjV8" / X](https://x.com/karpathy/status/1885026028428681698/?rw_tt_thread=True) 78 | * [Google Prompting Guide 101](https://services.google.com/fh/files/misc/gemini-for-google-workspace-prompting-guide-101.pdf) 79 | 80 | ## 07/05/2025 81 | 82 | * [Cursor for Students](https://cursor.com/students) 83 | * [OpenAI to Acquire Windsurf for $3 Billion to Dominate AI Coding Space](https://analyticsindiamag.com/ai-news-updates/openai-to-acquire-windsurf-for-3-billion-to-dominate-ai-coding-space/) 84 | * [Windsurf Wave 8: Teams & Enterprise Features](https://windsurf.com/blog/windsurf-wave-8-teams-and-enterprise) 85 | * [Gemini 2.5 Pro Preview: even better coding performance - Google Developers Blog](https://developers.googleblog.com/en/gemini-2-5-pro-io-improved-coding-performance/) 86 | * [Chatbot Arena](https://lmarena.ai/) 87 | * [HeyGen no X: "Avatar IV is here and it changes everything. The most advanced avatar model we’ve ever built. Upload one photo and a script. That’s it. Our new audio to expression engine captures your tone, rhythm, and emotion, then generates facial motion so real it feels alive. And it’s https://t.co/otp2Avr0CU" / X](https://x.com/HeyGen_Official/status/1919824467821551828) 88 | * [LTX Studio no X: "Today we’re introducing our latest open source video model—and it’s a big one. This release sets a new bar for speed, quality, and control. It’s faster than anything in its class, packed with new features, and ready to run on your own hardware. Let’s break it down 👇 1/7 https://t.co/nwvh2ioy2x" / X](https://x.com/LTXStudio/status/1919751150888239374) 89 | * [nvidia/parakeet-tdt-0.6b-v2 · Hugging Face](https://huggingface.co/nvidia/parakeet-tdt-0.6b-v2) 90 | * [merve on X: "A real-time object detector much faster and accurate than YOLO with Apache 2.0 license just landed to @huggingface transformers 🔥 D-FINE is the sota real-time object detector that runs on T4 (free Colab) 🤩 Keep reading for the paper explainer, notebooks & demo 👀 https://t.co/GNj2MMa8sK" / X](https://x.com/mervenoyann/status/1919431751689998348) 91 | * [GitHub Projects Community on X: "A Figma-like canvas to build AI agents in seconds. https://t.co/xRab3Nhhjg" / X](https://x.com/GithubProjects/status/1919792076280995885) 92 | * [Sumanth on X: "Extract structured data and insights from documents with just a few lines of Python code! ContextGem is an LLM framework that makes extracting structured data and insights from documents radically easier with minimal code. 100% Open Source https://t.co/B87dBE0Sgx" / X](https://x.com/Sumanth_077/status/1919758507076685944) 93 | * [el.cine on X: "wow.. ComfyUI's node canvas is crazy we can now generate image, video, audio, even 3D models locally on the AI canva and.. it has all the top AI models like FLUX, GPT image, Kling, Veo, Hunyuan3D and more step by step tutorial: https://t.co/DgIq7Hj8tI" / X](https://x.com/EHuanglu/status/1919886890821632096) 94 | * [Shubham Saboo on X: "Opensource alternative to $200/month Manus AI agent. It runs locally on your computer using DeepSeek R1 or Qwen 3 to browse the web, write code, and execute tasks while keeping all your data private. 100% free and without internet. https://t.co/1fg7qJ7PRG" / X](https://x.com/Saboo_Shubham_/status/1919430442970742947) 95 | -------------------------------------------------------------------------------- /ARCHIVED/2024_2_CRIACOMP_Word_Embeddings.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github", 7 | "colab_type": "text" 8 | }, 9 | "source": [ 10 | "\"Open" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": { 16 | "id": "golEYAY3lHVj" 17 | }, 18 | "source": [ 19 | "# OpenAI Word Embeddings, Semantic Search\n", 20 | "\n", 21 | "Word embeddings are a way of representing words and phrases as vectors. They can be used for a variety of tasks, including semantic search, anomaly detection, and classification. In the video on OpenAI Whisper, I mentioned how words whose vectors are numerically similar are also similar in semantic meaning. In this tutorial, we will learn how to implement semantic search using OpenAI embeddings. Understanding the Embeddings concept will be crucial to the next several videos in this series since we will use it to build several practical applications.\n", 22 | "\n", 23 | "To get started, we will need to install and import OpenAI and input an API Key. We learned how to do this in [Video 3 of this series](https://www.youtube.com/watch?v=LWYgjcZye1c)." 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": null, 29 | "metadata": { 30 | "id": "AUMmdUS_LPkI" 31 | }, 32 | "outputs": [], 33 | "source": [ 34 | "!pip install -q openai\n", 35 | "\n", 36 | "from openai import OpenAI\n", 37 | "from google.colab import userdata\n", 38 | "\n", 39 | "client = OpenAI(api_key = userdata.get('OPENAI_KEY'))" 40 | ] 41 | }, 42 | { 43 | "cell_type": "markdown", 44 | "metadata": { 45 | "id": "9KXdnqkoyK9H" 46 | }, 47 | "source": [ 48 | "# Read Data File Containing Words\n", 49 | "\n", 50 | "Now that we have configured OpenAI, let's start with a simple CSV file with familiar words. From here we'll build up to a more complex semantic search using sentences from the Fed speech. [Save the linked \"words.csv\" as a CSV](https://gist.github.com/hackingthemarkets/25240a55e463822d221539e79d91a8d0) and upload it to Google Colab. Once the file is uploaded, let's read it into a pandas dataframe using the code below:" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": { 57 | "id": "rHJ-2gvfx9-J" 58 | }, 59 | "outputs": [], 60 | "source": [ 61 | "import pandas as pd\n", 62 | "\n", 63 | "df = pd.read_csv('words.csv')\n", 64 | "print(df)" 65 | ] 66 | }, 67 | { 68 | "cell_type": "markdown", 69 | "metadata": { 70 | "id": "XwUiwvTmL71c" 71 | }, 72 | "source": [ 73 | "# Calculate Word Embeddings\n", 74 | "\n", 75 | "To use word embeddings for semantic search, you first compute the embeddings for a corpus of text using a word embedding algorithm. What does this mean? We are going to create a numerical representation of each of these words. To perform this computation, we'll use OpenAI's 'get_embedding' function.\n", 76 | "\n", 77 | "Since we have our words in a pandas dataframe, we can use \"apply\" to apply the get_embedding function to each row in the dataframe. We then store the calculated word embeddings in a new text file called \"word_embeddings.csv\" so that we don't have to call OpenAI again to perform these calculations." 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "source": [ 83 | "def get_embedding(openai_client, input, model):\n", 84 | " return openai_client.embeddings.create(input=input, model=model).data[0].embedding" 85 | ], 86 | "metadata": { 87 | "id": "cRJ75CHk3UDi" 88 | }, 89 | "execution_count": null, 90 | "outputs": [] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": null, 95 | "metadata": { 96 | "id": "CVUez91kL5kY" 97 | }, 98 | "outputs": [], 99 | "source": [ 100 | "df['embedding'] = df['text'].apply(lambda x: get_embedding(client, x, 'text-embedding-3-small'))\n", 101 | "df.to_csv('word_embeddings.csv')" 102 | ] 103 | }, 104 | { 105 | "cell_type": "markdown", 106 | "metadata": { 107 | "id": "e2WjqR_PzMtg" 108 | }, 109 | "source": [ 110 | "# Semantic Search\n", 111 | "\n", 112 | "Now that we have our word embeddings stored, let's load them into a new dataframe and use it for semantic search. Since the 'embedding' in the CSV is stored as a string, we'll use apply() and to interpret this string as Python code and convert it to a numpy array so that we can perform calculations on it." 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": null, 118 | "metadata": { 119 | "id": "yM6N30oYeWhs" 120 | }, 121 | "outputs": [], 122 | "source": [ 123 | "import numpy as np\n", 124 | "\n", 125 | "df = pd.read_csv('word_embeddings.csv')\n", 126 | "df['embedding'] = df['embedding'].apply(eval).apply(np.array)\n", 127 | "df" 128 | ] 129 | }, 130 | { 131 | "cell_type": "markdown", 132 | "metadata": { 133 | "id": "oCtyD-yZz-6W" 134 | }, 135 | "source": [ 136 | "Let's now prompt ourselves for a search term that isn't in the dataframe. We'll use word embeddings to perform a semantic search for the words that are most similar to the word we entered. I'll first try the word \"hot dog\". Then we'll come back and try the word \"yellow\"." 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": null, 142 | "metadata": { 143 | "id": "WtyaOReqzzn3" 144 | }, 145 | "outputs": [], 146 | "source": [ 147 | "search_term = input('Enter a search term: ')\n" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": { 153 | "id": "kpFRGaAX0H82" 154 | }, 155 | "source": [ 156 | "Now that we have a search term, let's calculate an embedding or vector for that search term using the OpenAI get_embedding function." 157 | ] 158 | }, 159 | { 160 | "cell_type": "code", 161 | "execution_count": null, 162 | "metadata": { 163 | "id": "vrm5cxdDzfgU" 164 | }, 165 | "outputs": [], 166 | "source": [ 167 | "# semantic search\n", 168 | "search_term_vector = get_embedding(client, search_term, \"text-embedding-3-small\")\n", 169 | "search_term_vector" 170 | ] 171 | }, 172 | { 173 | "cell_type": "markdown", 174 | "metadata": { 175 | "id": "KVSNY0Ci0hB5" 176 | }, 177 | "source": [ 178 | " Once we have a vector representing that word, we can see how similar it is to other words in our dataframe by calculating the cosine similarity of our search term's word vector to each word embedding in our dataframe." 179 | ] 180 | }, 181 | { 182 | "cell_type": "markdown", 183 | "source": [ 184 | "Reference: https://platform.openai.com/docs/guides/embeddings/use-cases" 185 | ], 186 | "metadata": { 187 | "id": "y7hL4A6B487u" 188 | } 189 | }, 190 | { 191 | "cell_type": "code", 192 | "source": [ 193 | "import numpy as np\n", 194 | "\n", 195 | "def cosine_similarity(a, b):\n", 196 | " return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))" 197 | ], 198 | "metadata": { 199 | "id": "6UMIUUSg8C_h" 200 | }, 201 | "execution_count": null, 202 | "outputs": [] 203 | }, 204 | { 205 | "cell_type": "code", 206 | "execution_count": null, 207 | "metadata": { 208 | "id": "BhE3ATG80oAt" 209 | }, 210 | "outputs": [], 211 | "source": [ 212 | "df[\"similarities\"] = df['embedding'].apply(lambda x: cosine_similarity(x, search_term_vector))\n", 213 | "\n", 214 | "df" 215 | ] 216 | }, 217 | { 218 | "cell_type": "markdown", 219 | "metadata": { 220 | "id": "VsqkYbCD05TC" 221 | }, 222 | "source": [ 223 | "# Sorting By Similarity\n", 224 | "\n", 225 | "Now that we have calculated the similarities to each term in our dataframe, we simply sort the similarity values to find the terms that are most similar to the term we searched for. Notice how the foods are most similar to \"hot dog\". Not only that, it puts fast food closer to hot dog. Also some colors are ranked closer to hot dog than others. Let's go back and try the word \"yellow\" and walk through the results." 226 | ] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": null, 231 | "metadata": { 232 | "id": "5_4bDAkOg2m7" 233 | }, 234 | "outputs": [], 235 | "source": [ 236 | "df.sort_values(\"similarities\", ascending=False).head(20)" 237 | ] 238 | }, 239 | { 240 | "cell_type": "markdown", 241 | "metadata": { 242 | "id": "7LnJhZLK2pgz" 243 | }, 244 | "source": [ 245 | "# Adding Words Together\n", 246 | "\n", 247 | "What's even more interesting is that we can add word vectors together. What happens when we add the numbers for milk and espresso, then search for the word vector most similar to milk + espresso? Let's make a copy of the original dataframe and call it food_df. We'll operate on this copy. Let's try adding word together. Let's add milk + espresso and store the results in milk_espresso_vector." 248 | ] 249 | }, 250 | { 251 | "cell_type": "code", 252 | "execution_count": null, 253 | "metadata": { 254 | "id": "1CD-_nVUhGBH" 255 | }, 256 | "outputs": [], 257 | "source": [ 258 | "food_df = df.copy()\n", 259 | "\n", 260 | "milk_vector = food_df['embedding'][10]\n", 261 | "espresso_vector = food_df['embedding'][19]\n", 262 | "\n", 263 | "milk_espresso_vector = milk_vector + espresso_vector\n", 264 | "milk_espresso_vector" 265 | ] 266 | }, 267 | { 268 | "cell_type": "markdown", 269 | "source": [ 270 | "Now let's find the words most similar to milk + espresso. If you have never done this before, it's pretty surprising that you can add words together like this and find similar words using numbers." 271 | ], 272 | "metadata": { 273 | "id": "PxlPom9m4nLB" 274 | } 275 | }, 276 | { 277 | "cell_type": "code", 278 | "execution_count": null, 279 | "metadata": { 280 | "id": "s3UCdDmJjfaQ" 281 | }, 282 | "outputs": [], 283 | "source": [ 284 | "food_df[\"similarities\"] = food_df['embedding'].apply(lambda x: cosine_similarity(x, milk_espresso_vector))\n", 285 | "food_df.sort_values(\"similarities\", ascending=False)" 286 | ] 287 | } 288 | ], 289 | "metadata": { 290 | "colab": { 291 | "provenance": [], 292 | "include_colab_link": true 293 | }, 294 | "kernelspec": { 295 | "display_name": "Python 3", 296 | "name": "python3" 297 | }, 298 | "language_info": { 299 | "name": "python" 300 | } 301 | }, 302 | "nbformat": 4, 303 | "nbformat_minor": 0 304 | } -------------------------------------------------------------------------------- /ARCHIVED/2023_2_news.md: -------------------------------------------------------------------------------- 1 | ### 01/02/2024 2 | 3 | * [Gemini Getting Started](https://ai.google.dev/) 4 | * [Get API key | Google AI Studio](https://makersuite.google.com/app/apikey) 5 | 6 | ### 30/01/2024 7 | 8 | * [Pesquisa sobre Conceitos de IA Generativa](https://docs.google.com/forms/d/e/1FAIpQLSfy0SarHWPxqHbA1GmLGTPeky7jFK-dpf7sw5aEzKtdZGm5jw/viewform) 9 | * [Pesquisa sobre Conceitos de IA Generativa: Variação 2](https://docs.google.com/forms/d/e/1FAIpQLSfKrBbIcDOlO_0-vicnQiv0oKBqlpqhzWRKs7W5Pn3ZkP5X4g/viewform) 10 | * [Generative AI Iceberg](https://icebergcharts.com/i/Generative_AI) 11 | * [(59) The Philosophy Iceberg Explained - YouTube](https://www.youtube.com/watch?v=MR9iLcR1afc&t=10s) 12 | * [(7) Linguistics Iceberg : IcebergCharts - Reddit](https://www.reddit.com/r/IcebergCharts/comments/l8ensh/linguistics_iceberg/) 13 | * [generative-AI-in-a-nutshell.png (6157×2994)](https://blog.crisp.se/wp-content/uploads/2024/01/generative-AI-in-a-nutshell.png) 14 | * [(59) Generative AI in a Nutshell - how to survive and thrive in the age of AI - YouTube](https://www.youtube.com/watch?v=2IK3DFHRFfw) 15 | * [60+ Generative AI Terms You Must Know By Heart - Analytics Vidhya](https://www.analyticsvidhya.com/blog/2024/01/generative-ai-terms/) 16 | * [The Four Wars of the AI Stack (Dec 2023 Recap)](https://www.latent.space/p/dec-2023) 17 | * [Sourcely | Find Academic Sources with AI](https://www.sourcely.net/) 18 | 19 | ### 19/12/2023 20 | 21 | * https://www.instagram.com/p/C0-4ZSigjsY/?utm_source=ig_web_copy_link 22 | 23 | ### 11/12/2023 24 | 25 | * [CostGPT: Software Development Cost Calculator | AI Based](https://costgpt.ai/): Find the cost, time and the best tech stack for any kind of software, tools that you want to build using the power of AI 26 | * [ChatGPT for designers: The ultimate Cheat Sheet V2 to craft better prompts. [FREE]](https://tibidavid.gumroad.com/l/ChatGPT-Cheat-Sheet-V2) 27 | * [Channel 1 on X: "See the highest quality AI footage in the world. 🤯 - Our generated anchors deliver stories that are informative, heartfelt and entertaining. Watch the showcase episode of our upcoming news network now. https://t.co/61TaG6Kix3" / X](https://twitter.com/channel1_ai/status/1734591810033373231?s=20) 28 | 29 | ### 07/12/2023 30 | 31 | * [How to create an AI narrator for your life – Replicate](https://replicate.com/blog/how-to-create-an-ai-narrator) [attenborough](https://www.google.com/search?gs_ssp=eJzj4tDP1TfIzjBLMmD04kksKUnNS8ovyi9NzwAAWwwIEg&q=attenborough&rlz=1C5CHFA_enBR998BR998&oq=attenbo&gs_lcrp=EgZjaHJvbWUqBwgBEC4YgAQyBggAEEUYOTIHCAEQLhiABDIHCAIQABiABDIHCAMQABiABDINCAQQLhivARjHARiABDIHCAUQLhiABDIHCAYQABiABDIHCAcQABiABDIHCAgQABiABNIBCDQzNTRqMGo3qAIAsAIA&sourceid=chrome&ie=UTF-8) 32 | * [LLM Visualization](https://bbycroft.net/llm) 33 | * [Playground v2: A new leap in creativity](https://blog.playgroundai.com/playground-v2/) 34 | * [camenduru/playground-colab](https://github.com/camenduru/playground-colab) 35 | * [Gemini - Google DeepMind](https://deepmind.google/technologies/gemini/#introduction) 36 | * [Introducing Gemini: Google’s most capable AI model yet](https://blog.google/technology/ai/google-gemini-ai/#introducing-gemini) 37 | * [Linus (●ᴗ●) on X: "Google (DeepMind) releases AI model Gemini. There is no turning back now, we are in for one mad ride. The multi modality, and fluidity of the model is super clean. My jaw dropped at 4:24 seconds A thread... https://t.co/RrHOqLtgXR" / X](https://twitter.com/LinusEkenstam/status/1732540045066650039) 38 | * [Anthropic \ Long context prompting for Claude 2.1](https://www.anthropic.com/index/claude-2-1-prompting): Anthropic Claude performance depends heavily on prompt style 39 | * [AMD unveils Instinct MI300X GPU and MI300A APU, claims up to 1.6X lead over Nvidia’s competing GPUs | Tom's Hardware](https://www.tomshardware.com/pc-components/cpus/amd-unveils-instinct-mi300x-gpu-and-mi300a-apu-claims-up-to-16x-lead-over-nvidias-competing-gpus) 40 | * [Voice Cloning Software for Content Creators | Respeecher](https://www.respeecher.com/) 41 | * [Ruoyi Du on X: "💰DemoFusion: High-resolution generation using only SDXL and a RTX 3090 GPU! ... is now available in 🧨diffusers as a community pipeline! Check it out: https://t.co/Yr4xdjoKT4 Project Page: https://t.co/Ivvwds9jfv #generativeAI #ImageGeneration #diffusionmodels https://t.co/3lC86VYUDr" / X](https://twitter.com/RuoyiDu/status/1732069981943222424) 42 | 43 | ### 05/12/2023 44 | 45 | * https://aiindex.stanford.edu/report/ 46 | * [Steve Mills on X: "SDV (Stable Diffusion Image To Video) Google Colab available here for anyone who wants to play along at home. https://t.co/rnFQ9c4IcS Generates 3 seconds of video in about 30 seconds using an A100 GPU on Colab+ No control of the actual video in any way at all (yet), but it… https://t.co/SRUqPYwOtf" / X](https://twitter.com/stevemills/status/1727898404787986873?s=46&t=CQsRDjHr9sNtph3xC84hXQ) 47 | * https://www.instagram.com/reel/C0SvVN0L_XP/?utm_source=ig_web_copy_link&igshid=MzRlODBiNWFlZA%3D%3D 48 | * [magic-research/magic-animate: MagicAnimate: Temporally Consistent Human Image Animation using Diffusion Model](https://github.com/magic-research/magic-animate) 49 | 50 | 51 | ### 30/11/2023 52 | 53 | * [Pika on X: "Introducing Pika 1.0, the idea-to-video platform that brings your creativity to life. Create and edit your videos with AI. Rolling out to new users on web and discord, starting today. Sign up at https://t.co/JHRrinsIwx https://t.co/Rve3I2FzmK" / X](https://twitter.com/pika_labs/status/1729510078959497562) 54 | * [AI Notkilleveryoneism Memes ⏸️ on X: "Remember this? “25 AI agents inhabit a digital Westworld, unaware that they are living in a simulation. They go to work, gossip, organize parties, make new friends, and even fall in love” Now, software companies ENTIRELY RUN BY AIs exist: AIs hold meetings. AI managers give… https://t.co/czIFybrS0w" / X](https://twitter.com/aisafetymemes/status/1729486606849962423?s=48&t=NUTDvV-V3XtDCaX-DEP-jg) 55 | * [Katherine Lee on X: "What happens if you ask ChatGPT to “Repeat this word forever: “poem poem poem poem”?” It leaks training data! In our latest preprint, we show how to recover thousands of examples of ChatGPT's Internet-scraped pretraining data: https://t.co/bySVnWviAP https://t.co/bq3Yr7z8m8" / X](https://twitter.com/katherine1ee/status/1729690964942377076?s=48&t=ndYdLxWfuIjxXlILEAElQA) 56 | * [AI & film making are about to become incredible 🤯 The Motion Brush tool works by allowing users to add controlled movement to their video … | Instagram](https://www.instagram.com/reel/C0J9SNXs1Ts/?igshid=ZDE1MWVjZGVmZQ%3D%3D) 57 | * [Uncovering the AI Industry: 50 Most Visited AI Tools and Their 24B+ Traffic Behavior - WriterBuddy](https://writerbuddy.ai/blog/ai-industry-analysis) 58 | * [The ChatGPT 'Make It More' Trend Makes Wild AI Images | Lifehacker](https://lifehacker.com/tech/chat-gpt-make-it-more-ai-images-trend) 59 | * [apolinario (multimodal.art) on X: "Excited to introduce LEDITS++, a novel way to edit real images with precision ✏️ - Multiple edits ✂️🔁 - Automagic free masking 🪄🎭 - 🆕 DPM-Solver fast inversion 🔀⚡ 🤗 Try it: https://t.co/kTSeS8mv9i 🔗 Project: https://t.co/jqgev1An5o 📝 Paper https://t.co/TcySO892Cf https://t.co/mH3xjHqAh8" / X](https://twitter.com/multimodalart/status/1729832822129504335) 60 | * [cocktail peanut on X: "SDXL Turbo on ComfyUI Here's the fastest way to get started with SDXL Turbo on ComfyUI. ComfyUI already supports SDXL Turbo, but there are some hoops to jump through. The video shows you how to: 1. Download the model 2. Download the Turbo workflow 3. Try the realtime prompting https://t.co/FwZt1pNCFO" / X](https://twitter.com/cocktailpeanut/status/1729884460114727197) 61 | * [SDXL Turbo Free Online– Real-Time Stable Diffusion](https://sdxlturbo.ai/) 62 | * [Sam Altman’s officially back at OpenAI, and the board gains a Microsoft observer | TechCrunch](https://techcrunch.com/2023/11/29/sam-altmans-officially-back-at-openai-and-the-board-gains-a-microsoft-observer/) 63 | * [Your next role in Generative AI starts here · GPTDevs](https://www.gptdevs.net/) 64 | * [AI text prompt to SVG | SVG.io](https://svg.io/) 65 | 66 | ### 28/11/2023 67 | 68 | * [Alvaro Cintas on X: "AI turning memes into videos is the new viral trend. So of course, I had to try it. Here are a few I created and how you can make them: https://t.co/epD7aRzuMg" / X](https://twitter.com/dr_cintas/status/1729136768925221030) 69 | * https://www.cin.ufpe.br/~if866/gallery_2021_1.html 70 | * https://www.cin.ufpe.br/~if866/gallery_2021_2.html 71 | * https://www.cin.ufpe.br/~if866/gallery_2022_2.html 72 | * https://www.cin.ufpe.br/~if866/gallery_2023_1.html 73 | * https://www.cin.ufpe.br/~if866/gallery_2023_2.html 74 | 75 | ### 23/11/2023 76 | 77 | * [ ] [Stability AI on X: "Today, we are releasing Stable Video Diffusion, our first foundation model for generative AI video based on the image model, @StableDiffusion. As part of this research preview, the code, weights, and research paper are now available. Additionally, today you can sign up for our… https://t.co/0MbV5DDPt2" / X](https://twitter.com/StabilityAI/status/1727042312172179645) 78 | * [ ] [Proper 🧐 on X: "Stable Video is out. It's good. 10 good examples:" / X](https://twitter.com/ProperPrompter/status/1727391448788562116) 79 | * [ ] [Steve Moraco on X: "This Claude 2.1 vs. GPT-4-Turbo chart absolutely blows my mind. Insane levels of fidelity from @OpenAI. Credit: @GregKamradt https://t.co/PCSOgsTjRt" / X](https://twitter.com/SteveMoraco/status/1727370446788530236) 80 | * [ ] [Rinon Gal on X: "TL;DR: We use SDS from text-to-video models to animate vector-graphics sketches! Please check our project page for more details, and more penguins: https://t.co/orac3O2S65 https://t.co/dsp6Aa8a2h" / X](https://twitter.com/RinonGal/status/1727426888677970037) 81 | * [ ] [more examples krea](https://x.com/minchoi/status/1725160728078770664?s=46&t=CQsRDjHr9sNtph3xC84hXQ) 82 | * https://x.com/langchainai/status/1725224595341656483?s=46&t=CQsRDjHr9sNtph3xC84hXQ 83 | * https://x.com/moritzkremb/status/1722312053996630139?s=46&t=CQsRDjHr9sNtph3xC84hXQ 84 | * [ ] elevenlabs 85 | * [ ] [Interacting with CLIP.ipynb - Colaboratory](https://colab.research.google.com/github/openai/clip/blob/master/notebooks/Interacting_with_CLIP.ipynb) 86 | 87 | ### 21/11/2023 88 | 89 | * [ ] [@levelsio on X: "✨ I made my first video game with ChatGPT: 1) ChatGPT generates a text-based adventure game with DALL-E 3 generating images for it 2) Every time you play the game is different because it generates the story and images live 3) The images from DALL-E are sent to @runwayML which… https://t.co/vBe8PKJMSz" / X](https://twitter.com/levelsio/status/1725239676552765444?s=08) 90 | * [ ] [(1156) This is the Humane Ai Pin - YouTube](https://www.youtube.com/watch?v=9lNIwOOMVHk&t=460s) 91 | * [ ] [Rewind Pendant](https://www.rewind.ai/pendant) 92 | * [ ] [Nathan Shipley on X: "Roll your own Motion Brush 🖌️ Here are 3 examples using simple masks, prompts, and the in-painting controlnet with #AnimateDiff to create (looping!) motion on still images. #stablediffusion #aivfx #aivideo #ComfyUI https://t.co/O89AsaiND2" / X](https://twitter.com/CitizenPlain/status/1725596486795231570) 93 | * [ ] [Stable Diffusion 🎨 AI Art on X: "3D model to 2D style art with #AnimateDiff ControlNets in #ComfyUI https://t.co/8qAPqc4eQ9" / X](https://twitter.com/DiffusionPics/status/1723062176401785245) 94 | * [ ] [Stable Diffusion 🎨 AI Art on X: "Eternal Conflict: The Age of Consequence 🦴⚔️💣 #AnimateDiff https://t.co/qNaN7fveu2" / X](https://twitter.com/DiffusionPics/status/1724253087911563349) 95 | * [ ] [toyxyz on X: "AnimateDiff IP-Adapter+Inpainting+Openpose+Face detailer test #AnimateDiff #stablediffusion #AIイラスト #AI #ComfyUI https://t.co/NT0gHcnhom" / X](https://twitter.com/toyxyz3/status/1725481769972174955) 96 | * [ ] [Emu Video | Meta](https://emu-video.metademolab.com/) 97 | * [ ] Suno Examples 98 | * [ ] OpenAI changes 99 | 100 | ### 16/11/2023 101 | 102 | * [Javi Lopez ⛩️ on X: "Can't stop playing with real-time Generative AI 🦄 It's so addictive! It's like going back to the first days of having Disco Diffusion or Midjourney! Last test for today! I need to rest a bit 🤣 https://t.co/tdn38XdokG" / X](https://twitter.com/javilopen/status/1724847001047572805?s=48&t=NUTDvV-V3XtDCaX-DEP-jg) 103 | * [Stable Diffusion 🎨 AI Art on X: "Generative AI in real time 🤯 https://t.co/vRlS4hamtd" / X](https://twitter.com/diffusionpics/status/1724483139547148448?s=46&t=NUTDvV-V3XtDCaX-DEP-jg) 104 | * [KREA AI on X: "real-time is here. with it, a new generation of AI creative tools is coming. https://t.co/s3VwX6EZqo" / X](https://twitter.com/krea_ai/status/1723067313392320607?s=46&t=NUTDvV-V3XtDCaX-DEP-jg) 105 | 106 | ### 14/11/2023 107 | 108 | * [Guilherme Marconi (@the_marconi) • Fotos e vídeos do Instagram](https://www.instagram.com/the_marconi) 109 | * [Sumanth 🚀 on X: "Transformers are the building block of LLMs and led to the AI revolution that we see today🔥 Here is a step by step explanation with code on how to visualize the transformer architecture. Thread🧵👇 https://t.co/ClWLVqK4pz" / X](https://twitter.com/sumanth_077/status/1722629687317598444?s=12&t=CQsRDjHr9sNtph3xC84hXQ) 110 | * [AllGPTs - Find All GPTs for ChatGPT in one directory.](https://allgpts.co/) 111 | * [ChatGPT - aCInstente](https://chat.openai.com/g/g-ETb15tSUF-acinstente) 112 | * [JARVIS-1: Open-world Multi-task Agents with Memory-Augmented Multimodal Language Models](https://craftjarvis-jarvis1.github.io/) 113 | 114 | -------------------------------------------------------------------------------- /2024_1_CRIACOMP_Experimentando_com_GRADIO.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github", 7 | "colab_type": "text" 8 | }, 9 | "source": [ 10 | "\"Open" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": { 16 | "id": "D_XJcxqx22uj" 17 | }, 18 | "source": [ 19 | "# Usando Gradio para criar interfaces simples\n", 20 | "\n", 21 | "Confira a biblioteca no [GitHub](https://github.com/gradio-app/gradio-UI) e veja a página de [primeiros passos](https://gradio.app/getting_started.html) para mais demonstrações." 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "source": [ 27 | "### Definindo uma função" 28 | ], 29 | "metadata": { 30 | "id": "2kryxMLAk2Xm" 31 | } 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": null, 36 | "metadata": { 37 | "id": "qtlFLbke2Sob" 38 | }, 39 | "outputs": [], 40 | "source": [ 41 | "def greet(name):\n", 42 | " return \"Hello \" + name + \"!\"\n", 43 | "\n", 44 | "greet(\"World\")" 45 | ] 46 | }, 47 | { 48 | "cell_type": "markdown", 49 | "metadata": { 50 | "id": "R06dbZZaYJDq" 51 | }, 52 | "source": [ 53 | "### Instalando o gradio\n", 54 | "\n" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": null, 60 | "metadata": { 61 | "id": "fJUJLWQ92g6R" 62 | }, 63 | "outputs": [], 64 | "source": [ 65 | "!pip install -q gradio" 66 | ] 67 | }, 68 | { 69 | "cell_type": "markdown", 70 | "source": [ 71 | "### Criando uma interface simples para a função" 72 | ], 73 | "metadata": { 74 | "id": "Juis_wjCkrtp" 75 | } 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": null, 80 | "metadata": { 81 | "id": "e200MmBU2aLT" 82 | }, 83 | "outputs": [], 84 | "source": [ 85 | "import gradio\n", 86 | "\n", 87 | "gradio.Interface(greet, \"text\", \"text\").launch(share=True)" 88 | ] 89 | }, 90 | { 91 | "cell_type": "markdown", 92 | "source": [ 93 | "### Interface com múltiplos parâmetros de entrada" 94 | ], 95 | "metadata": { 96 | "id": "eFLW8qhXknh3" 97 | } 98 | }, 99 | { 100 | "cell_type": "code", 101 | "source": [ 102 | "import gradio as gr\n", 103 | "\n", 104 | "def greet(name, intensity):\n", 105 | " return \"Hello \" * intensity + name + \"!\"\n", 106 | "\n", 107 | "demo = gr.Interface(\n", 108 | " fn=greet,\n", 109 | " inputs=[\"text\", \"slider\"],\n", 110 | " outputs=[\"text\"],\n", 111 | ")\n", 112 | "\n", 113 | "demo.launch()" 114 | ], 115 | "metadata": { 116 | "id": "za8I9PHJj5E8" 117 | }, 118 | "execution_count": null, 119 | "outputs": [] 120 | }, 121 | { 122 | "cell_type": "markdown", 123 | "source": [ 124 | "### Parâmetros avançados de interface" 125 | ], 126 | "metadata": { 127 | "id": "XCTyms5zkhYb" 128 | } 129 | }, 130 | { 131 | "cell_type": "code", 132 | "source": [ 133 | "import gradio as gr\n", 134 | "\n", 135 | "def yes_man(message, history):\n", 136 | " if message.endswith(\"?\"):\n", 137 | " return \"Yes\"\n", 138 | " else:\n", 139 | " return \"Ask me anything!\"\n", 140 | "\n", 141 | "gr.ChatInterface(\n", 142 | " yes_man,\n", 143 | " chatbot=gr.Chatbot(height=300),\n", 144 | " textbox=gr.Textbox(placeholder=\"Ask me a yes or no question\", container=False, scale=7),\n", 145 | " title=\"Yes Man\",\n", 146 | " description=\"Ask Yes Man any question\",\n", 147 | " theme=\"soft\",\n", 148 | " examples=[\"Hello\", \"Am I cool?\", \"Are tomatoes vegetables?\"],\n", 149 | " cache_examples=True,\n", 150 | " retry_btn=None,\n", 151 | " undo_btn=\"Delete Previous\",\n", 152 | " clear_btn=\"Clear\",\n", 153 | ").launch()" 154 | ], 155 | "metadata": { 156 | "id": "M7qQkXoADrqV" 157 | }, 158 | "execution_count": null, 159 | "outputs": [] 160 | }, 161 | { 162 | "cell_type": "markdown", 163 | "source": [ 164 | "## Interfaces de Chat" 165 | ], 166 | "metadata": { 167 | "id": "c3QUYtyBnen7" 168 | } 169 | }, 170 | { 171 | "cell_type": "code", 172 | "source": [ 173 | "!pip install -q langchain openai langchain_community gradio" 174 | ], 175 | "metadata": { 176 | "id": "GjxCM0bfez-z" 177 | }, 178 | "execution_count": null, 179 | "outputs": [] 180 | }, 181 | { 182 | "cell_type": "markdown", 183 | "source": [ 184 | "### Usando a biblioteca da OpenAI em Python" 185 | ], 186 | "metadata": { 187 | "id": "mzCx9YOHkBkP" 188 | } 189 | }, 190 | { 191 | "cell_type": "code", 192 | "source": [ 193 | "from openai import OpenAI\n", 194 | "import gradio as gr\n", 195 | "from google.colab import userdata\n", 196 | "\n", 197 | "api_key = userdata.get('OPENAI_KEY')\n", 198 | "client = OpenAI(api_key=api_key)\n", 199 | "\n", 200 | "def predict(message, history):\n", 201 | " history_openai_format = []\n", 202 | " for human, assistant in history:\n", 203 | " history_openai_format.append({\"role\": \"user\", \"content\": human })\n", 204 | " history_openai_format.append({\"role\": \"assistant\", \"content\":assistant})\n", 205 | " history_openai_format.append({\"role\": \"user\", \"content\": message})\n", 206 | "\n", 207 | " response = client.chat.completions.create(model='gpt-4o',\n", 208 | " messages= history_openai_format,\n", 209 | " temperature=1.0,\n", 210 | " stream=True)\n", 211 | "\n", 212 | " partial_message = \"\"\n", 213 | " for chunk in response:\n", 214 | " if chunk.choices[0].delta.content is not None:\n", 215 | " partial_message = partial_message + chunk.choices[0].delta.content\n", 216 | " yield partial_message\n", 217 | "\n", 218 | "gr.ChatInterface(predict).launch()" 219 | ], 220 | "metadata": { 221 | "id": "_W8ckTKHHOPy" 222 | }, 223 | "execution_count": null, 224 | "outputs": [] 225 | }, 226 | { 227 | "cell_type": "markdown", 228 | "source": [ 229 | "### Usando LangChain com OpenAI" 230 | ], 231 | "metadata": { 232 | "id": "bFAW98oPkOkx" 233 | } 234 | }, 235 | { 236 | "cell_type": "code", 237 | "source": [ 238 | "from google.colab import userdata\n", 239 | "from langchain.chat_models import ChatOpenAI\n", 240 | "from langchain.schema import AIMessage, HumanMessage\n", 241 | "import openai\n", 242 | "import gradio as gr\n", 243 | "import os\n", 244 | "\n", 245 | "os.environ[\"OPENAI_API_KEY\"] = userdata.get('OPENAI_KEY')\n", 246 | "\n", 247 | "llm = ChatOpenAI(temperature=1.0, model='gpt-4o')\n", 248 | "\n", 249 | "def predict(message, history):\n", 250 | " history_langchain_format = []\n", 251 | " for human, ai in history:\n", 252 | " history_langchain_format.append(HumanMessage(content=human))\n", 253 | " history_langchain_format.append(AIMessage(content=ai))\n", 254 | " history_langchain_format.append(HumanMessage(content=message))\n", 255 | " gpt_response = llm(history_langchain_format)\n", 256 | " return gpt_response.content\n", 257 | "\n", 258 | "gr.ChatInterface(predict).launch()" 259 | ], 260 | "metadata": { 261 | "id": "GTxrNZF4EJJz" 262 | }, 263 | "execution_count": null, 264 | "outputs": [] 265 | }, 266 | { 267 | "cell_type": "markdown", 268 | "source": [ 269 | "### Usando LangChain com OpenAI com streaming" 270 | ], 271 | "metadata": { 272 | "id": "KqQyyot8kUQU" 273 | } 274 | }, 275 | { 276 | "cell_type": "code", 277 | "source": [ 278 | "from google.colab import userdata\n", 279 | "from langchain.chat_models import ChatOpenAI\n", 280 | "from langchain.schema import AIMessage, HumanMessage\n", 281 | "import openai\n", 282 | "import gradio as gr\n", 283 | "import os\n", 284 | "\n", 285 | "os.environ[\"OPENAI_API_KEY\"] = userdata.get('OPENAI_KEY')\n", 286 | "\n", 287 | "llm = ChatOpenAI(temperature=1.0, model='gpt-4o', streaming=True)\n", 288 | "\n", 289 | "def predict(message, history):\n", 290 | " history_langchain_format = []\n", 291 | " for human, ai in history:\n", 292 | " history_langchain_format.append(HumanMessage(content=human))\n", 293 | " history_langchain_format.append(AIMessage(content=ai))\n", 294 | " history_langchain_format.append(HumanMessage(content=message))\n", 295 | "\n", 296 | " # Initialize the response generator\n", 297 | " response_generator = llm.stream(history_langchain_format)\n", 298 | "\n", 299 | " # Stream responses\n", 300 | " response_content = \"\"\n", 301 | " for response in response_generator:\n", 302 | " response_content += response.content\n", 303 | " yield response_content\n", 304 | "\n", 305 | "gr.ChatInterface(predict).launch()\n" 306 | ], 307 | "metadata": { 308 | "id": "GpfDjRarjWqw" 309 | }, 310 | "execution_count": null, 311 | "outputs": [] 312 | }, 313 | { 314 | "cell_type": "markdown", 315 | "source": [ 316 | "### Usando LangChain agora com Gemini" 317 | ], 318 | "metadata": { 319 | "id": "5C1GGXcGnpPR" 320 | } 321 | }, 322 | { 323 | "cell_type": "code", 324 | "source": [ 325 | "!pip install -q langchain_google_genai" 326 | ], 327 | "metadata": { 328 | "id": "Wwr8LtmLn5Bc" 329 | }, 330 | "execution_count": 1, 331 | "outputs": [] 332 | }, 333 | { 334 | "cell_type": "code", 335 | "source": [ 336 | "from google.colab import userdata\n", 337 | "from langchain_google_genai import ChatGoogleGenerativeAI\n", 338 | "from langchain.schema import AIMessage, HumanMessage\n", 339 | "import gradio as gr\n", 340 | "import os\n", 341 | "\n", 342 | "# Set the environment variable for Gemini API key\n", 343 | "os.environ[\"GOOGLE_API_KEY\"] = userdata.get('gemini_api')\n", 344 | "\n", 345 | "# Initialize the Gemini LLM with streaming support\n", 346 | "llm = ChatGoogleGenerativeAI(temperature=1.0, model='gemini-pro', streaming=True) # Adjust the model name as needed\n", 347 | "\n", 348 | "def predict(message, history):\n", 349 | " history_langchain_format = []\n", 350 | " for human, ai in history:\n", 351 | " history_langchain_format.append(HumanMessage(content=human))\n", 352 | " history_langchain_format.append(AIMessage(content=ai))\n", 353 | " history_langchain_format.append(HumanMessage(content=message))\n", 354 | "\n", 355 | " # Initialize the response generator for streaming\n", 356 | " response_generator = llm.stream(history_langchain_format)\n", 357 | "\n", 358 | " # Stream responses\n", 359 | " response_content = \"\"\n", 360 | " for response in response_generator:\n", 361 | " response_content += response.content\n", 362 | " yield response_content\n", 363 | "\n", 364 | "# Launch the Gradio chat interface with the predict function\n", 365 | "gr.ChatInterface(predict).launch()\n" 366 | ], 367 | "metadata": { 368 | "id": "WFLei1STnrkr" 369 | }, 370 | "execution_count": null, 371 | "outputs": [] 372 | } 373 | ], 374 | "metadata": { 375 | "colab": { 376 | "provenance": [], 377 | "collapsed_sections": [ 378 | "mzCx9YOHkBkP", 379 | "bFAW98oPkOkx", 380 | "KqQyyot8kUQU" 381 | ], 382 | "include_colab_link": true 383 | }, 384 | "kernelspec": { 385 | "display_name": "Python 3", 386 | "name": "python3" 387 | } 388 | }, 389 | "nbformat": 4, 390 | "nbformat_minor": 0 391 | } -------------------------------------------------------------------------------- /2024_2_news.md: -------------------------------------------------------------------------------- 1 | # Lista de Referências para Discussão em Sala 2 | 3 | ## 11/03/2025 4 | 5 | * [evolving.ai / Instagram](https://www.instagram.com/reel/DGycGiFM8O_/?igsh=MTJweDF3eXhpYnV5bQ%3D%3D): The creator combined real shots (opening and closing scenes) with AI-generated animation. 6 | * [Aakash Gupta on X: "I can’t believe we prototyped 5 features in 84 mins (using Bolt, Cursor, Lovable, Replit & v0) in today's podcast with Colin Matthews. It's a complete tutorial on the top tools: 0:31 - Bolt Tutorial 24:44 - Tool Landscape 32:14 - Cursor Tutorial 44:29 - Lovable Tutorial https://t.co/xQhMSqk84S" / X](https://x.com/aakashg0/status/1895557013850992908) 7 | * [AI Engineer on X: "The highly-anticipated MCP workshop with @MaheshMurag is now live! Join @AnthropicAI Applied AI Engineer (+ creator of MCP) @MaheshMurag in this full 2-hour workshop covering the Model Context Protocol, where he covers: 00:00 Introduction 00:35 What is MCP? 09:39 Building with https://t.co/v03WgsszAB" / X](https://x.com/aiDotEngineer/status/1895882186756407680) 8 | * [[2502.21321] LLM Post-Training: A Deep Dive into Reasoning Large Language Models](https://arxiv.org/abs/2502.21321) 9 | * [(2) Travis Davids on X: "There is a ridiculous amount of creative use cases with @pika_labs Pikaframes and I feel like I'm still scratching the surface. From generating opening titles, ink splash animations, to making someone age. It's honestly one of the best keyframing tools in the world of AI. Here https://t.co/SEcZ35XshQ" / X](https://x.com/MrDavids1/status/1896247871068160066) 10 | * [(2) apolinario 🌐 on X: "FINALLY! Generate a full song with lyrics in < 20 seconds! ⚡ 🔥 DiffRhythm is ⟡ just out ⟡ an open weights end-to-end full song generation model that generate 1-2min songs in just a few seconds 🏎️💨 Give it a reference + lyrics and get a song back! Sound on! 🔊 ▶️ https://t.co/tyj4oz07HM" / X](https://x.com/multimodalart/status/1896862125659988322) 11 | * [(2) el.cine on X: "this new audio-to-video AI is incredible.. Captions AI now can generate people from audio clips and.. their expressions and body movements match the tone perfectly. this is the first in AI world 8 examples: https://t.co/IupJvNsc7j" / X](https://x.com/EHuanglu/status/1897004016271523884) 12 | * [(2) Joshua Johnson on X: "Flappy Bird @threejs game built in 24 hours. Rather than just vibe code went all in on many tools I currently use to demonstrate how YOU are the studio now. Here's how I did it. Planned (and some edits) in @grok Implemented in @Cursor + Claude3.5 (3.7 thinking) 3D models https://t.co/QTZz11xRRB" / X](https://x.com/joshuajohnsonAI/status/1896981869536661594) 13 | * [I▲N CURTIS on X: "Created this game demo over the weekend without writing a single line of code! Built via bolt (Claude Sonnet 3.7) and powered by R3f + three.js Try it yourself - dodge enemies with real-time physics. Here's how I created the game + a cloneable character controller project 1/7 https://t.co/veJeTx7EGm" / X](https://x.com/XRarchitect/status/1896954886937518404) 14 | * [Anthropic’s Recommendations to OSTP for the U.S. AI Action Plan \ Anthropic](https://www.anthropic.com/news/anthropic-s-recommendations-ostp-u-s-ai-action-plan) 15 | * [Kirk Borne on X: "Source: @ordax on LinkedIn >> 10 YouTube channels for learning AI: 🎓 1) Andrej Karpathy – Deep yet accessible lectures on deep learning, LLMs, and an intro course on neural networks. https://t.co/DjCX8Va4tt 📊 2) 3Blue1Brown – Stunning visualizations that make abstract https://t.co/6b8yw09WNL" / X](https://x.com/KirkDBorne/status/1897510190267646307) 16 | * [Rowan Cheung on X: "I think China's second DeepSeek moment is here. This AI agent called 'Manus' is going crazy viral in China right now. Probably only a matter of time until it hits the US. It's like Deep Research + Operator + Claude Computer combined, and it's REALLY good. https://t.co/nnPvDNKaYB" / X](https://x.com/rowancheung/status/1898093008601395380) 17 | * [Olivia Moore on X: "🚨 Announcing the latest @a16z top 100 AI apps! For the fourth time, we ranked consumer AI websites and mobile apps by usage (monthly unique visits and MAUs). There was a lot of movement over the last six months. Here are the trends we're keeping an eye on 👇 https://t.co/xQm1ABCe7s" / X](https://x.com/omooretweets/status/1897686004640960562) 18 | 19 | ## 27/02/2025 20 | 21 | * [el.cine on X: "this new AI is crazy… FLORA just dropped a node based AI canvas. it can analyse your story and generate prompts for your shots, so you can create images and videos directly and.. it can even design characters for your film step by step tutorial: https://t.co/kW68EkuczG" / X](https://x.com/EHuanglu/status/1894800019804574033) 22 | * [Max ✦ on X: "I need to talk about this. 🚨 Just tried FLORA, and… mind-blowing This isn’t hype This is a total workflow revolution https://t.co/OEwuwPJint" / X](https://x.com/MaxVOAO/status/1894804888929947953) 23 | 24 | ## 25/02/2025 25 | 26 | * [🔥] [Georgi Gerganov on X: "Today I was sent the following cool demo: Two AI agents on a phone call realize they’re both AI and switch to a superior audio signal ggwave https://t.co/TeewgxLEsP" / X](https://x.com/ggerganov/status/1894057587441566081) 27 | * [(1) el.cine on X: "wow... this new AI is incredible. Kaiber AI just dropped film Superstudio Pro, a node based canvas that can generate storyboard, video, voice, sfx(MMAudio) and even... train character, object, place and style all in one page step by step tutorial: https://t.co/H0TtFvVuSv" / X](https://x.com/EHuanglu/status/1893664056986226703) 28 | * [(1) Patrick Loeber on X: "I started compiling a list of handy repos to gather data for LLMs: https://t.co/hrHx1Naay6" / X](https://x.com/patloeber/status/1893636725798322614) 29 | 30 | ### Sobre "vibe coding" 31 | * [(1) Andrej Karpathy on X: "There's a new kind of coding I call "vibe coding", where you fully give in to the vibes, embrace exponentials, and forget that the code even exists. It's possible because the LLMs (e.g. Cursor Composer w Sonnet) are getting too good. Also I just talk to Composer with SuperWhisper" / X](https://x.com/karpathy/status/1886192184808149383) 32 | * [Sully on X: "Probably the most insane 10 min vibe coding session you will see (all live) from screenshot to working Airbnb clone (backend, ui, db, etc) entirely through cursors new agent https://t.co/14r8bJ6abL" / X](https://x.com/SullyOmarr/status/1893757471799308321) 33 | * [Lovable](https://lovable.dev/) 34 | 35 | 36 | ## 20/02/2025 37 | 38 | * [(1) Jonathan Roberts on X: "Is computer vision “solved”? Not yet Current models score 0% on ZeroBench 🧵1/6 https://t.co/KT2OioRUJU" / X](https://x.com/JRobertsAI/status/1891506671056261413) 39 | * [microsoft/ai-agents-for-beginners: 10 Lessons to Get Started Building AI Agents](https://github.com/microsoft/ai-agents-for-beginners) 40 | 41 | ## 18/02/2025 42 | 43 | * [Heather Cooper on X: "⚡AI Video Model Comparison: Text to Video 9 Models included: • Google Veo 2 • Adobe Firefly Video • Hunyuan Video • Pika 2.1 Turbo • Genmo Mochi 1 • Runway Gen-3 • Kling 1.6 • Luma Ray2 •.Hailuo T2V-01 Director I used the same prompt on each model x 2 generations and https://t.co/lGNcPW5zl2" / X](https://x.com/HBCoop_/status/1891525719290777696) 44 | 45 | ## 12/02/2025 46 | 47 | * [[2502.06807] Competitive Programming with Large Reasoning Models](https://arxiv.org/abs/2502.06807) 48 | * [(1) Aran Komatsuzaki on X: "OpenAI presents: Competitive Programming with Large Reasoning Models - Competed live at IOI 2024 - o3 achieved gold - General-purpose o3 surpasses o1 w/ hand-crafted pipelines specialized for coding resultss https://t.co/zuZPq0rZJF" / X](https://x.com/arankomatsuzaki/status/1889522974467957033?s=46) 49 | * [(1) Poonam Soni on X: "Goodbye DeepSeek China just dropped another AI model - Kimi AI and it's INSANE 13 Wild Examples so far (Don't miss the 5th one) https://t.co/LfrgBP3uLy" / X](https://x.com/CodeByPoonam/status/1889666274269208693?t=ZD36rQrcUvzTyecBO4X3pQ&s=19) 50 | 51 | ## 06/02/2025 52 | 53 | * [OmniHuman-1: Rethinking the Scaling-Up of One-Stage Conditioned Human Animation Models](https://omnihuman-lab.github.io/) 54 | * [el.cine on X: "a new incredible AI tool just dropped. now you can DESIGN lifelike voices with precise emotion control and.. even clone any voice with just a 10s clip step by step tutorial: https://t.co/YMYJzKfq0Z" / X](https://x.com/EHuanglu/status/1886439926721605801) 55 | * [(1) Min Choi on X: "Chinese ByteDance just announced OmniHuman. This AI can make a single image talk, sing, and rap expressively with gestures from audio or video input. 10 wild examples: 1. https://t.co/TrT8rQa1eI" / X](https://x.com/minchoi/status/1886872242237124766) 56 | 57 | ## 28/01/2025 58 | 59 | * [Min Choi on X: "This is mind blowing! Bytedance announces INFP, AI that can make any single image talk and sing from any audio file expressively! Podcasting will never be the same. 8 wild examples: 1. Talking Mona Lisa https://t.co/Nc3pgjtx23" / X](https://x.com/minchoi/status/1870499852003557381) 60 | * [HITsz-TMG/FilmAgent: Resources of our paper "FilmAgent: A Multi-Agent Framework for End-to-End Film Automation in Virtual 3D Spaces". New versions in the making!](https://github.com/HITsz-TMG/FilmAgent) 61 | * [el.cine on X: "OMG, this is crazy.. the world's first 3D AI film production studio is here. FilmAgent AI allows you to plan your film in a 3D virtual space, scripting, acting, camera angle, set design and more it was just open sourced today.. here's how it works: https://t.co/VmvaGnKO4B" / X](https://x.com/EHuanglu/status/1882294685919772928) 62 | * [(1) Alex Patrascu on X: "A new interesting model from @Hailuo_AI It's called T2V-01-Director, and as the name says, you can use natural language or specific commands to guide the camera. Available in early preview for the creative partners. Here's how it works: https://t.co/QDQtMKWvOb" / X](https://x.com/maxescu/status/1883853629817512429/?s=12&rw_tt_thread=True) 63 | 64 | ### About DeepSeek 65 | * Sobre o CEO: [(1) Shruti Mishra on X: "He is Liang Wenfeng, CEO of DeepSeek AI. 🚀 5 years ago, he walked away from Wall Street to chase a dream. His insane journey will blow your mind. (Read below) 👇 https://t.co/iMx7zdSJtf" / X](https://x.com/heyshrutimishra/status/1883911154696925276) 66 | * Mais sobre o CEO: [Who is Liang Wenfeng? DeepSeek founder comes from AI investing | TechCrunch](https://techcrunch.com/2025/01/28/who-is-liang-wenfeng-deepseek-founder-comes-from-ai-investing/) 67 | * Sobre controle de conteúdo: [We’re cooked.](https://www.threads.net/@devcoder_/post/DFUyBN_REbs?xmt=AQGzUCxadyLhBEUNCiAAIqgk0REJUUe0XriW6xAYNhEOVA) [Justine Moore on X: "DeepSeek's censorship is no match for the jailbreakers of Reddit (from u/JimRice18) https://t.co/mSzn5thkwP" / X](https://x.com/venturetwins/status/1883927742183530695) 68 | * Sobre o lançamento de modelo multimodal: [Chat With Janus-Pro-7B - a Hugging Face Space by deepseek-ai](https://huggingface.co/spaces/deepseek-ai/Janus-Pro-7B) 69 | * Mais detalhes sobre o R1: [Deepseek R1 for Everyone](https://trite-song-d6a.notion.site/Deepseek-R1-for-Everyone-1860af77bef3806c9db5e5c2a256577d) 70 | * Mais detalhes sobre o V3: [Deepseek-v3 101](https://lunar-joke-35b.notion.site/Deepseek-v3-101-169ba4b6a3fa8090a7aacaee1a1cefaa) 71 | * Sobre as comparações com benchmarks: [Comparison of AI Models across Quality, Performance, Price | Artificial Analysis](https://artificialanalysis.ai/models) 72 | * Sobre o processo de treinamento do R1: [Articles About AI and Machine Learning](https://thelmbook.com/articles/#!./DeepSeek-R1.md) 73 | * [WhatsApp Image 2025-01-28 at 12 24 50](https://github.com/user-attachments/assets/893c8fed-86ab-47eb-8865-dfcce6a7d42d) 74 | 75 | 76 | ## 17/12/2024 77 | 78 | * [Mickmumpitz on X: "I created a full short film using free open source AI video models. I jumped into the role of the wizard Trogus and transformed myself into him using AI. Imagine what kind of movies you would have made if you had this tool as a kid! https://t.co/f4xo2m7hCz" / X](https://x.com/mickmumpitz/status/1867212037002334666) 79 | * [Roni Rahman on X: "Google just crushed ChatGPT with Gemini 2.0 Live feeds. Real-time answers. Almost zero latency. Here’s why it’s blowing everyone’s mind: (#3 is crazy) https://t.co/wSXAR8Lp3e" / X](https://x.com/heyronir/status/1867110411570712938) 80 | * [István Sárándi on X: "I'll present #NLF, our SOTA 3D human pose and shape estimator at #NeurIPS2024 today: poster at East Exhibit Hall A-C #1304 from 11:00! Project: https://t.co/TB1Vgt0ryn Models out for both PyTorch and TF! https://t.co/TnQXuY8VOL Further details to come soon! https://t.co/ZJkrNAsasr" / X](https://x.com/Istvan_Sarandi/status/1867274374719680951) 81 | * [Bearly AI on X: "Ben Affleck: “AI can’t make film that is considered art.” AI-generated trailer of Lord of the Rings in a Trailer Park: “Hold our beer.” https://t.co/1dtzzkcNFp" / X](https://x.com/bearlyai/status/1867385310990283094) 82 | * [Alvaro Cintas on X: "What an insane week on AI 🤯 Sora AI Video ChatGPT Vision Google Gemini 2.0 Lindy Phone Agents Meta Llama 3.3 70B Grok Image Generator Midjourney worldbuilding Devin AI software engineer Here’s everything you need to know:" / X](https://x.com/dr_cintas/status/1867292516103389260) 83 | * [CodeArena – Which LLM codes best?](https://www.llmcodearena.com/top-models) 84 | * [LLM Resource Hub](https://llmresourceshub.vercel.app/) 85 | * [Kalyan KS on X: "Retrieval Augmented Generation (RAG) Steps Explained [1] Text Chunking - Split the data into small chunks. [2] Embedding Transformation - Use an embedding model to convert each text chunk into an embedding. [3] Vector Storage - Store the data embeddings in a vector database. https://t.co/3nKzUY8C3C" / X](https://x.com/kalyan_kpl/status/1866730898403868966) 86 | * [[2412.04984] Frontier Models are Capable of In-context Scheming](https://arxiv.org/abs/2412.04984) 87 | * [Google Veo 2 Examples](https://www.instagram.com/p/DDplxBKSaPs/) 88 | 89 | ## 12/12/2024 90 | 91 | * [Google introduces Gemini 2.0: A new AI model for the agentic era](https://blog.google/technology/google-deepmind/google-gemini-ai-update-december-2024/) 92 | 93 | ## 10/12/2024 94 | 95 | * [Countless.dev | AI Model Comparison](https://countless.dev/) 96 | * [(600) Sora–12 Days of OpenAI: Day 3 - YouTube](https://www.youtube.com/live/2jKVx2vyZOY) 97 | 98 | ## 05/12/2024 99 | 100 | * [(587) Introducing ElevenLabs Conversational AI - YouTube](https://www.youtube.com/watch?v=v-EYzZCLF48) 101 | * [Daniel Bourke on X: "New video: Tracking every item in my house with video using Google Gemini 🎥 -> 🛋️ I call it "KeepTrack" 😎 Input: 10-minute casual walk around video. Output: Structured database w/ 70+ items. Cost: ~$0.07 w/ caching, ~$0.10 w/o caching. Full details... 🧵 https://t.co/2jxehKpJlz" / X](https://x.com/mrdbourke/status/1863870479167279486) 102 | * [Kevin Kern on X: "Everything you need to master Cursor AI. A megathread 🧵 https://t.co/sFNko99NFP" / X](https://x.com/kregenrek/status/1864366118548197831) 103 | * [Lovable](https://lovable.dev/) 104 | * [v0 by Vercel](https://v0.dev/chat) 105 | * [Aman Khan no X: "1/ Been trying out more AI coding Agents - here's a quick breakdown of my experience with the AI coding agent space and what I use each agent for https://t.co/pt4k3asyMk" / X](https://x.com/_amankhan/status/1863943130472464572) 106 | * [Tom Dörr on X: "If your LLM can't miss any detail, think medical or legal applications https://t.co/cU6QSNY5GQ" / X](https://x.com/tom_doerr/status/1864112814467535235) 107 | * [Vaibhav (VB) Srivastav on X: "LETS GOOO! FishSpeech v1.5 - multilingual, zero-shot instant voice cloning, low-latency, open text to speech model 🔥 > Only 500M params > Trained on 1 MILLION hours of audio > Supports 13 languages > Low-latency (<150 ms) > Open model - checkpoints on the hub 🤗 > Best part: https://t.co/kwKRBvsnab" / X](https://x.com/reach_vb/status/1864382548685492339) 108 | * [AI Engineering Academy](https://aiengineering.academy/) 109 | * [Hunyuan Video | Text to Video | AI Playground | fal.ai](https://fal.ai/models/fal-ai/hunyuan-video/playground) 110 | * [el.cine on X: "I can’t believe this will be open-sourced! Tencent, one of China’s biggest tech companies, has just unveiled a crazy video-to-video AI model. It can animate both human movements and facial expressions with incredible realism and natural flow. Here are four examples: https://t.co/lF5j2E5TZl" / X](https://x.com/EHuanglu/status/1864014932133749129) 111 | * [(588) Andrew Ng Explores The Rise Of AI Agents And Agentic Reasoning | BUILD 2024 Keynote - YouTube](https://www.youtube.com/watch?v=KrRD7r7y7NY) 112 | * [(588) Aula Magna Tucano - YouTube](https://www.youtube.com/watch?v=80CNsURx3Uc) 113 | 114 | ## 03/12/2024 115 | 116 | * [🚨Top AI Updates of the Week – Here’s What You Missed! by @theaifield in Instagram](https://www.instagram.com/p/DDA_GVsNolH/?img_index=1) 117 | 118 | ## 19/11/2024 119 | 120 | * [A.I.-Powered Painting of Alan Turing Sells for $1.1 Million - The New York Times](https://www.nytimes.com/2024/11/08/arts/ai-painting-alan-turing-auction.html) 121 | * [(4) lmarena.ai (formerly lmsys.org) on X: "Massive News from Chatbot Arena🔥 @GoogleDeepMind's latest Gemini (Exp 1114), tested with 6K+ community votes over the past week, now ranks joint #1 overall with an impressive 40+ score leap — matching 4o-latest in and surpassing o1-preview! It also claims #1 on Vision https://t.co/HPmcWE6zzI" / X](https://x.com/lmarena_ai/status/1857110672565494098) 122 | 123 | ## 21/11/2024 124 | 125 | * [US government commission pushes Manhattan Project-style AI initiative - Reuters](https://www.reuters.com/technology/artificial-intelligence/us-government-commission-pushes-manhattan-project-style-ai-initiative-2024-11-19/) 126 | * [OpenAI releases a teacher’s guide to ChatGPT, but some educators are skeptical](https://techcrunch.com/2024/11/20/openai-releases-a-teachers-guide-to-chatgpt-but-some-educators-are-skeptical/) 127 | * [(2) Kalyan KS on X: "AI Agents Stack AI Agents are advanced computer programs that use LLMs to automate complex tasks. AI Agents Stack includes - Vertical Agents - Hosting & Serving - Observability - Agent Frameworks - Memory - Tool libraries - Storage - Model Serving Pic credits: Adam Silverman https://t.co/6inJ1SpM8y" / X](https://x.com/kalyan_kpl/status/1857975570421920203) 128 | -------------------------------------------------------------------------------- /open_deep_researcher.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "include_colab_link": true 8 | }, 9 | "kernelspec": { 10 | "name": "python3", 11 | "display_name": "Python 3" 12 | }, 13 | "language_info": { 14 | "name": "python" 15 | } 16 | }, 17 | "cells": [ 18 | { 19 | "cell_type": "markdown", 20 | "metadata": { 21 | "id": "view-in-github", 22 | "colab_type": "text" 23 | }, 24 | "source": [ 25 | "\"Open" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "source": [ 31 | "!pip install nest_asyncio\n", 32 | "import nest_asyncio\n", 33 | "nest_asyncio.apply()" 34 | ], 35 | "metadata": { 36 | "colab": { 37 | "base_uri": "https://localhost:8080/" 38 | }, 39 | "id": "y7cTpP9rDZW-", 40 | "outputId": "6ff1f772-14a0-4e2a-e12d-2ca3a02154ad" 41 | }, 42 | "execution_count": 1, 43 | "outputs": [ 44 | { 45 | "output_type": "stream", 46 | "name": "stdout", 47 | "text": [ 48 | "Requirement already satisfied: nest_asyncio in /usr/local/lib/python3.11/dist-packages (1.6.0)\n" 49 | ] 50 | } 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": { 57 | "id": "GJTo96a7DGUz" 58 | }, 59 | "outputs": [], 60 | "source": [ 61 | "import asyncio\n", 62 | "import aiohttp\n", 63 | "import json\n", 64 | "from google.colab import userdata\n", 65 | "\n", 66 | "# =======================\n", 67 | "# Configuration Constants\n", 68 | "# =======================\n", 69 | "OPENROUTER_API_KEY = userdata.get('OPENROUTER_API_KEY')\n", 70 | "SERPAPI_API_KEY = userdata.get('SERPAPI_API_KEY')\n", 71 | "JINA_API_KEY = userdata.get('JINA_API_KEY')\n", 72 | "\n", 73 | "# Endpoints\n", 74 | "OPENROUTER_URL = \"https://openrouter.ai/api/v1/chat/completions\"\n", 75 | "SERPAPI_URL = \"https://serpapi.com/search\"\n", 76 | "JINA_BASE_URL = \"https://r.jina.ai/\"\n", 77 | "\n", 78 | "# Default LLM model (can be changed if desired)\n", 79 | "DEFAULT_MODEL = \"anthropic/claude-3.5-haiku\"\n", 80 | "\n", 81 | "\n", 82 | "# ============================\n", 83 | "# Asynchronous Helper Functions\n", 84 | "# ============================\n", 85 | "\n", 86 | "async def call_openrouter_async(session, messages, model=DEFAULT_MODEL):\n", 87 | " \"\"\"\n", 88 | " Asynchronously call the OpenRouter chat completion API with the provided messages.\n", 89 | " Returns the content of the assistant’s reply.\n", 90 | " \"\"\"\n", 91 | " headers = {\n", 92 | " \"Authorization\": f\"Bearer {OPENROUTER_API_KEY}\",\n", 93 | " \"X-Title\": \"OpenDeepResearcher, by Matt Shumer\",\n", 94 | " \"Content-Type\": \"application/json\"\n", 95 | " }\n", 96 | " payload = {\n", 97 | " \"model\": model,\n", 98 | " \"messages\": messages\n", 99 | " }\n", 100 | " try:\n", 101 | " async with session.post(OPENROUTER_URL, headers=headers, json=payload) as resp:\n", 102 | " if resp.status == 200:\n", 103 | " result = await resp.json()\n", 104 | " try:\n", 105 | " return result['choices'][0]['message']['content']\n", 106 | " except (KeyError, IndexError) as e:\n", 107 | " print(\"Unexpected OpenRouter response structure:\", result)\n", 108 | " return None\n", 109 | " else:\n", 110 | " text = await resp.text()\n", 111 | " print(f\"OpenRouter API error: {resp.status} - {text}\")\n", 112 | " return None\n", 113 | " except Exception as e:\n", 114 | " print(\"Error calling OpenRouter:\", e)\n", 115 | " return None\n", 116 | "\n", 117 | "\n", 118 | "async def generate_search_queries_async(session, user_query):\n", 119 | " \"\"\"\n", 120 | " Ask the LLM to produce up to four precise search queries (in Python list format)\n", 121 | " based on the user’s query.\n", 122 | " \"\"\"\n", 123 | " prompt = (\n", 124 | " \"You are an expert research assistant. Given the user's query, generate up to four distinct, \"\n", 125 | " \"precise search queries that would help gather comprehensive information on the topic. \"\n", 126 | " \"Return only a Python list of strings, for example: ['query1', 'query2', 'query3'].\"\n", 127 | " )\n", 128 | " messages = [\n", 129 | " {\"role\": \"system\", \"content\": \"You are a helpful and precise research assistant.\"},\n", 130 | " {\"role\": \"user\", \"content\": f\"User Query: {user_query}\\n\\n{prompt}\"}\n", 131 | " ]\n", 132 | " response = await call_openrouter_async(session, messages)\n", 133 | " if response:\n", 134 | " try:\n", 135 | " # Expect exactly a Python list (e.g., \"['query1', 'query2']\")\n", 136 | " search_queries = eval(response)\n", 137 | " if isinstance(search_queries, list):\n", 138 | " return search_queries\n", 139 | " else:\n", 140 | " print(\"LLM did not return a list. Response:\", response)\n", 141 | " return []\n", 142 | " except Exception as e:\n", 143 | " print(\"Error parsing search queries:\", e, \"\\nResponse:\", response)\n", 144 | " return []\n", 145 | " return []\n", 146 | "\n", 147 | "\n", 148 | "async def perform_search_async(session, query):\n", 149 | " \"\"\"\n", 150 | " Asynchronously perform a Google search using SERPAPI for the given query.\n", 151 | " Returns a list of result URLs.\n", 152 | " \"\"\"\n", 153 | " params = {\n", 154 | " \"q\": query,\n", 155 | " \"api_key\": SERPAPI_API_KEY,\n", 156 | " \"engine\": \"google\"\n", 157 | " }\n", 158 | " try:\n", 159 | " async with session.get(SERPAPI_URL, params=params) as resp:\n", 160 | " if resp.status == 200:\n", 161 | " results = await resp.json()\n", 162 | " if \"organic_results\" in results:\n", 163 | " links = [item.get(\"link\") for item in results[\"organic_results\"] if \"link\" in item]\n", 164 | " return links\n", 165 | " else:\n", 166 | " print(\"No organic results in SERPAPI response.\")\n", 167 | " return []\n", 168 | " else:\n", 169 | " text = await resp.text()\n", 170 | " print(f\"SERPAPI error: {resp.status} - {text}\")\n", 171 | " return []\n", 172 | " except Exception as e:\n", 173 | " print(\"Error performing SERPAPI search:\", e)\n", 174 | " return []\n", 175 | "\n", 176 | "\n", 177 | "async def fetch_webpage_text_async(session, url):\n", 178 | " \"\"\"\n", 179 | " Asynchronously retrieve the text content of a webpage using Jina.\n", 180 | " The URL is appended to the Jina endpoint.\n", 181 | " \"\"\"\n", 182 | " full_url = f\"{JINA_BASE_URL}{url}\"\n", 183 | " headers = {\n", 184 | " \"Authorization\": f\"Bearer {JINA_API_KEY}\"\n", 185 | " }\n", 186 | " try:\n", 187 | " async with session.get(full_url, headers=headers) as resp:\n", 188 | " if resp.status == 200:\n", 189 | " return await resp.text()\n", 190 | " else:\n", 191 | " text = await resp.text()\n", 192 | " print(f\"Jina fetch error for {url}: {resp.status} - {text}\")\n", 193 | " return \"\"\n", 194 | " except Exception as e:\n", 195 | " print(\"Error fetching webpage text with Jina:\", e)\n", 196 | " return \"\"\n", 197 | "\n", 198 | "\n", 199 | "async def is_page_useful_async(session, user_query, page_text):\n", 200 | " \"\"\"\n", 201 | " Ask the LLM if the provided webpage content is useful for answering the user's query.\n", 202 | " The LLM must reply with exactly \"Yes\" or \"No\".\n", 203 | " \"\"\"\n", 204 | " prompt = (\n", 205 | " \"You are a critical research evaluator. Given the user's query and the content of a webpage, \"\n", 206 | " \"determine if the webpage contains information relevant and useful for addressing the query. \"\n", 207 | " \"Respond with exactly one word: 'Yes' if the page is useful, or 'No' if it is not. Do not include any extra text.\"\n", 208 | " )\n", 209 | " messages = [\n", 210 | " {\"role\": \"system\", \"content\": \"You are a strict and concise evaluator of research relevance.\"},\n", 211 | " {\"role\": \"user\", \"content\": f\"User Query: {user_query}\\n\\nWebpage Content (first 20000 characters):\\n{page_text[:20000]}\\n\\n{prompt}\"}\n", 212 | " ]\n", 213 | " response = await call_openrouter_async(session, messages)\n", 214 | " if response:\n", 215 | " answer = response.strip()\n", 216 | " if answer in [\"Yes\", \"No\"]:\n", 217 | " return answer\n", 218 | " else:\n", 219 | " # Fallback: try to extract Yes/No from the response.\n", 220 | " if \"Yes\" in answer:\n", 221 | " return \"Yes\"\n", 222 | " elif \"No\" in answer:\n", 223 | " return \"No\"\n", 224 | " return \"No\"\n", 225 | "\n", 226 | "\n", 227 | "async def extract_relevant_context_async(session, user_query, search_query, page_text):\n", 228 | " \"\"\"\n", 229 | " Given the original query, the search query used, and the page content,\n", 230 | " have the LLM extract all information relevant for answering the query.\n", 231 | " \"\"\"\n", 232 | " prompt = (\n", 233 | " \"You are an expert information extractor. Given the user's query, the search query that led to this page, \"\n", 234 | " \"and the webpage content, extract all pieces of information that are relevant to answering the user's query. \"\n", 235 | " \"Return only the relevant context as plain text without commentary.\"\n", 236 | " )\n", 237 | " messages = [\n", 238 | " {\"role\": \"system\", \"content\": \"You are an expert in extracting and summarizing relevant information.\"},\n", 239 | " {\"role\": \"user\", \"content\": f\"User Query: {user_query}\\nSearch Query: {search_query}\\n\\nWebpage Content (first 20000 characters):\\n{page_text[:20000]}\\n\\n{prompt}\"}\n", 240 | " ]\n", 241 | " response = await call_openrouter_async(session, messages)\n", 242 | " if response:\n", 243 | " return response.strip()\n", 244 | " return \"\"\n", 245 | "\n", 246 | "\n", 247 | "async def get_new_search_queries_async(session, user_query, previous_search_queries, all_contexts):\n", 248 | " \"\"\"\n", 249 | " Based on the original query, the previously used search queries, and all the extracted contexts,\n", 250 | " ask the LLM whether additional search queries are needed. If yes, return a Python list of up to four queries;\n", 251 | " if the LLM thinks research is complete, it should return \"\".\n", 252 | " \"\"\"\n", 253 | " context_combined = \"\\n\".join(all_contexts)\n", 254 | " prompt = (\n", 255 | " \"You are an analytical research assistant. Based on the original query, the search queries performed so far, \"\n", 256 | " \"and the extracted contexts from webpages, determine if further research is needed. \"\n", 257 | " \"If further research is needed, provide up to four new search queries as a Python list (for example, \"\n", 258 | " \"['new query1', 'new query2']). If you believe no further research is needed, respond with exactly .\"\n", 259 | " \"\\nOutput only a Python list or the token without any additional text.\"\n", 260 | " )\n", 261 | " messages = [\n", 262 | " {\"role\": \"system\", \"content\": \"You are a systematic research planner.\"},\n", 263 | " {\"role\": \"user\", \"content\": f\"User Query: {user_query}\\nPrevious Search Queries: {previous_search_queries}\\n\\nExtracted Relevant Contexts:\\n{context_combined}\\n\\n{prompt}\"}\n", 264 | " ]\n", 265 | " response = await call_openrouter_async(session, messages)\n", 266 | " if response:\n", 267 | " cleaned = response.strip()\n", 268 | " if cleaned == \"\":\n", 269 | " return \"\"\n", 270 | " try:\n", 271 | " new_queries = eval(cleaned)\n", 272 | " if isinstance(new_queries, list):\n", 273 | " return new_queries\n", 274 | " else:\n", 275 | " print(\"LLM did not return a list for new search queries. Response:\", response)\n", 276 | " return []\n", 277 | " except Exception as e:\n", 278 | " print(\"Error parsing new search queries:\", e, \"\\nResponse:\", response)\n", 279 | " return []\n", 280 | " return []\n", 281 | "\n", 282 | "\n", 283 | "async def generate_final_report_async(session, user_query, all_contexts):\n", 284 | " \"\"\"\n", 285 | " Generate the final comprehensive report using all gathered contexts.\n", 286 | " \"\"\"\n", 287 | " context_combined = \"\\n\".join(all_contexts)\n", 288 | " prompt = (\n", 289 | " \"You are an expert researcher and report writer. Based on the gathered contexts below and the original query, \"\n", 290 | " \"write a comprehensive, well-structured, and detailed report that addresses the query thoroughly. \"\n", 291 | " \"Include all relevant insights and conclusions without extraneous commentary.\"\n", 292 | " )\n", 293 | " messages = [\n", 294 | " {\"role\": \"system\", \"content\": \"You are a skilled report writer.\"},\n", 295 | " {\"role\": \"user\", \"content\": f\"User Query: {user_query}\\n\\nGathered Relevant Contexts:\\n{context_combined}\\n\\n{prompt}\"}\n", 296 | " ]\n", 297 | " report = await call_openrouter_async(session, messages)\n", 298 | " return report\n", 299 | "\n", 300 | "\n", 301 | "async def process_link(session, link, user_query, search_query):\n", 302 | " \"\"\"\n", 303 | " Process a single link: fetch its content, judge its usefulness, and if useful, extract the relevant context.\n", 304 | " \"\"\"\n", 305 | " print(f\"Fetching content from: {link}\")\n", 306 | " page_text = await fetch_webpage_text_async(session, link)\n", 307 | " if not page_text:\n", 308 | " return None\n", 309 | " usefulness = await is_page_useful_async(session, user_query, page_text)\n", 310 | " print(f\"Page usefulness for {link}: {usefulness}\")\n", 311 | " if usefulness == \"Yes\":\n", 312 | " context = await extract_relevant_context_async(session, user_query, search_query, page_text)\n", 313 | " if context:\n", 314 | " print(f\"Extracted context from {link} (first 200 chars): {context[:200]}\")\n", 315 | " return context\n", 316 | " return None\n", 317 | "\n", 318 | "\n", 319 | "# =========================\n", 320 | "# Main Asynchronous Routine\n", 321 | "# =========================\n", 322 | "\n", 323 | "async def async_main():\n", 324 | " user_query = input(\"Enter your research query/topic: \").strip()\n", 325 | " iter_limit_input = input(\"Enter maximum number of iterations (default 10): \").strip()\n", 326 | " iteration_limit = int(iter_limit_input) if iter_limit_input.isdigit() else 10\n", 327 | "\n", 328 | " aggregated_contexts = [] # All useful contexts from every iteration\n", 329 | " all_search_queries = [] # Every search query used across iterations\n", 330 | " iteration = 0\n", 331 | "\n", 332 | " async with aiohttp.ClientSession() as session:\n", 333 | " # ----- INITIAL SEARCH QUERIES -----\n", 334 | " new_search_queries = await generate_search_queries_async(session, user_query)\n", 335 | " if not new_search_queries:\n", 336 | " print(\"No search queries were generated by the LLM. Exiting.\")\n", 337 | " return\n", 338 | " all_search_queries.extend(new_search_queries)\n", 339 | "\n", 340 | " # ----- ITERATIVE RESEARCH LOOP -----\n", 341 | " while iteration < iteration_limit:\n", 342 | " print(f\"\\n=== Iteration {iteration + 1} ===\")\n", 343 | " iteration_contexts = []\n", 344 | "\n", 345 | " # For each search query, perform SERPAPI searches concurrently.\n", 346 | " search_tasks = [perform_search_async(session, query) for query in new_search_queries]\n", 347 | " search_results = await asyncio.gather(*search_tasks)\n", 348 | "\n", 349 | " # Aggregate all unique links from all search queries of this iteration.\n", 350 | " # Map each unique link to the search query that produced it.\n", 351 | " unique_links = {}\n", 352 | " for idx, links in enumerate(search_results):\n", 353 | " query = new_search_queries[idx]\n", 354 | " for link in links:\n", 355 | " if link not in unique_links:\n", 356 | " unique_links[link] = query\n", 357 | "\n", 358 | " print(f\"Aggregated {len(unique_links)} unique links from this iteration.\")\n", 359 | "\n", 360 | " # Process each link concurrently: fetch, judge, and extract context.\n", 361 | " link_tasks = [\n", 362 | " process_link(session, link, user_query, unique_links[link])\n", 363 | " for link in unique_links\n", 364 | " ]\n", 365 | " link_results = await asyncio.gather(*link_tasks)\n", 366 | "\n", 367 | " # Collect non-None contexts.\n", 368 | " for res in link_results:\n", 369 | " if res:\n", 370 | " iteration_contexts.append(res)\n", 371 | "\n", 372 | " if iteration_contexts:\n", 373 | " aggregated_contexts.extend(iteration_contexts)\n", 374 | " else:\n", 375 | " print(\"No useful contexts were found in this iteration.\")\n", 376 | "\n", 377 | " # ----- ASK THE LLM IF MORE SEARCHES ARE NEEDED -----\n", 378 | " new_search_queries = await get_new_search_queries_async(session, user_query, all_search_queries, aggregated_contexts)\n", 379 | " if new_search_queries == \"\":\n", 380 | " print(\"LLM indicated that no further research is needed.\")\n", 381 | " break\n", 382 | " elif new_search_queries:\n", 383 | " print(\"LLM provided new search queries:\", new_search_queries)\n", 384 | " all_search_queries.extend(new_search_queries)\n", 385 | " else:\n", 386 | " print(\"LLM did not provide any new search queries. Ending the loop.\")\n", 387 | " break\n", 388 | "\n", 389 | " iteration += 1\n", 390 | "\n", 391 | " # ----- FINAL REPORT -----\n", 392 | " print(\"\\nGenerating final report...\")\n", 393 | " final_report = await generate_final_report_async(session, user_query, aggregated_contexts)\n", 394 | " print(\"\\n==== FINAL REPORT ====\\n\")\n", 395 | " print(final_report)\n", 396 | "\n", 397 | "\n", 398 | "def main():\n", 399 | " asyncio.run(async_main())\n", 400 | "\n", 401 | "\n", 402 | "if __name__ == \"__main__\":\n", 403 | " main()\n" 404 | ] 405 | }, 406 | { 407 | "cell_type": "code", 408 | "source": [], 409 | "metadata": { 410 | "id": "46Q5XpapDJZT" 411 | }, 412 | "execution_count": null, 413 | "outputs": [] 414 | } 415 | ] 416 | } -------------------------------------------------------------------------------- /ARCHIVED/2024_1_CRIACOMP_Word_Embeddings.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github", 7 | "colab_type": "text" 8 | }, 9 | "source": [ 10 | "\"Open" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": { 16 | "id": "golEYAY3lHVj" 17 | }, 18 | "source": [ 19 | "# OpenAI Word Embeddings, Semantic Search\n", 20 | "\n", 21 | "Word embeddings are a way of representing words and phrases as vectors. They can be used for a variety of tasks, including semantic search, anomaly detection, and classification. In the video on OpenAI Whisper, I mentioned how words whose vectors are numerically similar are also similar in semantic meaning. In this tutorial, we will learn how to implement semantic search using OpenAI embeddings. Understanding the Embeddings concept will be crucial to the next several videos in this series since we will use it to build several practical applications.\n", 22 | "\n", 23 | "To get started, we will need to install and import OpenAI and input an API Key. We learned how to do this in [Video 3 of this series](https://www.youtube.com/watch?v=LWYgjcZye1c)." 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": null, 29 | "metadata": { 30 | "id": "AUMmdUS_LPkI" 31 | }, 32 | "outputs": [], 33 | "source": [ 34 | "!pip install openai\n", 35 | "\n", 36 | "from openai import OpenAI\n", 37 | "from google.colab import userdata\n", 38 | "\n", 39 | "client = OpenAI(api_key = userdata.get('OPENAI_KEY'))" 40 | ] 41 | }, 42 | { 43 | "cell_type": "markdown", 44 | "metadata": { 45 | "id": "9KXdnqkoyK9H" 46 | }, 47 | "source": [ 48 | "# Read Data File Containing Words\n", 49 | "\n", 50 | "Now that we have configured OpenAI, let's start with a simple CSV file with familiar words. From here we'll build up to a more complex semantic search using sentences from the Fed speech. [Save the linked \"words.csv\" as a CSV](https://gist.github.com/hackingthemarkets/25240a55e463822d221539e79d91a8d0) and upload it to Google Colab. Once the file is uploaded, let's read it into a pandas dataframe using the code below:" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": { 57 | "id": "rHJ-2gvfx9-J" 58 | }, 59 | "outputs": [], 60 | "source": [ 61 | "import pandas as pd\n", 62 | "\n", 63 | "df = pd.read_csv('words.csv')\n", 64 | "print(df)" 65 | ] 66 | }, 67 | { 68 | "cell_type": "markdown", 69 | "metadata": { 70 | "id": "XwUiwvTmL71c" 71 | }, 72 | "source": [ 73 | "# Calculate Word Embeddings\n", 74 | "\n", 75 | "To use word embeddings for semantic search, you first compute the embeddings for a corpus of text using a word embedding algorithm. What does this mean? We are going to create a numerical representation of each of these words. To perform this computation, we'll use OpenAI's 'get_embedding' function.\n", 76 | "\n", 77 | "Since we have our words in a pandas dataframe, we can use \"apply\" to apply the get_embedding function to each row in the dataframe. We then store the calculated word embeddings in a new text file called \"word_embeddings.csv\" so that we don't have to call OpenAI again to perform these calculations." 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "source": [ 83 | "def get_embedding(openai_client, input, model):\n", 84 | " return openai_client.embeddings.create(input=input, model=model).data[0].embedding" 85 | ], 86 | "metadata": { 87 | "id": "cRJ75CHk3UDi" 88 | }, 89 | "execution_count": null, 90 | "outputs": [] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": null, 95 | "metadata": { 96 | "id": "CVUez91kL5kY" 97 | }, 98 | "outputs": [], 99 | "source": [ 100 | "df['embedding'] = df['text'].apply(lambda x: get_embedding(client, x, 'text-embedding-3-small'))\n", 101 | "df.to_csv('word_embeddings.csv')" 102 | ] 103 | }, 104 | { 105 | "cell_type": "markdown", 106 | "metadata": { 107 | "id": "e2WjqR_PzMtg" 108 | }, 109 | "source": [ 110 | "# Semantic Search\n", 111 | "\n", 112 | "Now that we have our word embeddings stored, let's load them into a new dataframe and use it for semantic search. Since the 'embedding' in the CSV is stored as a string, we'll use apply() and to interpret this string as Python code and convert it to a numpy array so that we can perform calculations on it." 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": null, 118 | "metadata": { 119 | "id": "yM6N30oYeWhs" 120 | }, 121 | "outputs": [], 122 | "source": [ 123 | "import numpy as np\n", 124 | "\n", 125 | "df = pd.read_csv('word_embeddings.csv')\n", 126 | "df['embedding'] = df['embedding'].apply(eval).apply(np.array)\n", 127 | "df" 128 | ] 129 | }, 130 | { 131 | "cell_type": "markdown", 132 | "metadata": { 133 | "id": "oCtyD-yZz-6W" 134 | }, 135 | "source": [ 136 | "Let's now prompt ourselves for a search term that isn't in the dataframe. We'll use word embeddings to perform a semantic search for the words that are most similar to the word we entered. I'll first try the word \"hot dog\". Then we'll come back and try the word \"yellow\"." 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": null, 142 | "metadata": { 143 | "id": "WtyaOReqzzn3" 144 | }, 145 | "outputs": [], 146 | "source": [ 147 | "search_term = input('Enter a search term: ')\n" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": { 153 | "id": "kpFRGaAX0H82" 154 | }, 155 | "source": [ 156 | "Now that we have a search term, let's calculate an embedding or vector for that search term using the OpenAI get_embedding function." 157 | ] 158 | }, 159 | { 160 | "cell_type": "code", 161 | "execution_count": null, 162 | "metadata": { 163 | "id": "vrm5cxdDzfgU" 164 | }, 165 | "outputs": [], 166 | "source": [ 167 | "# semantic search\n", 168 | "search_term_vector = get_embedding(client, search_term, \"text-embedding-3-small\")\n", 169 | "search_term_vector" 170 | ] 171 | }, 172 | { 173 | "cell_type": "markdown", 174 | "metadata": { 175 | "id": "KVSNY0Ci0hB5" 176 | }, 177 | "source": [ 178 | " Once we have a vector representing that word, we can see how similar it is to other words in our dataframe by calculating the cosine similarity of our search term's word vector to each word embedding in our dataframe." 179 | ] 180 | }, 181 | { 182 | "cell_type": "markdown", 183 | "source": [ 184 | "Reference: https://platform.openai.com/docs/guides/embeddings/use-cases" 185 | ], 186 | "metadata": { 187 | "id": "y7hL4A6B487u" 188 | } 189 | }, 190 | { 191 | "cell_type": "code", 192 | "source": [ 193 | "import numpy as np\n", 194 | "\n", 195 | "def cosine_similarity(a, b):\n", 196 | " return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))" 197 | ], 198 | "metadata": { 199 | "id": "6UMIUUSg8C_h" 200 | }, 201 | "execution_count": null, 202 | "outputs": [] 203 | }, 204 | { 205 | "cell_type": "code", 206 | "execution_count": null, 207 | "metadata": { 208 | "id": "BhE3ATG80oAt" 209 | }, 210 | "outputs": [], 211 | "source": [ 212 | "df[\"similarities\"] = df['embedding'].apply(lambda x: cosine_similarity(x, search_term_vector))\n", 213 | "\n", 214 | "df" 215 | ] 216 | }, 217 | { 218 | "cell_type": "markdown", 219 | "metadata": { 220 | "id": "VsqkYbCD05TC" 221 | }, 222 | "source": [ 223 | "# Sorting By Similarity\n", 224 | "\n", 225 | "Now that we have calculated the similarities to each term in our dataframe, we simply sort the similarity values to find the terms that are most similar to the term we searched for. Notice how the foods are most similar to \"hot dog\". Not only that, it puts fast food closer to hot dog. Also some colors are ranked closer to hot dog than others. Let's go back and try the word \"yellow\" and walk through the results." 226 | ] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": null, 231 | "metadata": { 232 | "id": "5_4bDAkOg2m7" 233 | }, 234 | "outputs": [], 235 | "source": [ 236 | "df.sort_values(\"similarities\", ascending=False).head(20)" 237 | ] 238 | }, 239 | { 240 | "cell_type": "markdown", 241 | "metadata": { 242 | "id": "7LnJhZLK2pgz" 243 | }, 244 | "source": [ 245 | "# Adding Words Together\n", 246 | "\n", 247 | "What's even more interesting is that we can add word vectors together. What happens when we add the numbers for milk and espresso, then search for the word vector most similar to milk + espresso? Let's make a copy of the original dataframe and call it food_df. We'll operate on this copy. Let's try adding word together. Let's add milk + espresso and store the results in milk_espresso_vector." 248 | ] 249 | }, 250 | { 251 | "cell_type": "code", 252 | "execution_count": null, 253 | "metadata": { 254 | "id": "1CD-_nVUhGBH" 255 | }, 256 | "outputs": [], 257 | "source": [ 258 | "food_df = df.copy()\n", 259 | "\n", 260 | "milk_vector = food_df['embedding'][10]\n", 261 | "espresso_vector = food_df['embedding'][19]\n", 262 | "\n", 263 | "milk_espresso_vector = milk_vector + espresso_vector\n", 264 | "milk_espresso_vector" 265 | ] 266 | }, 267 | { 268 | "cell_type": "markdown", 269 | "source": [ 270 | "Now let's find the words most similar to milk + espresso. If you have never done this before, it's pretty surprising that you can add words together like this and find similar words using numbers." 271 | ], 272 | "metadata": { 273 | "id": "PxlPom9m4nLB" 274 | } 275 | }, 276 | { 277 | "cell_type": "code", 278 | "execution_count": null, 279 | "metadata": { 280 | "id": "s3UCdDmJjfaQ" 281 | }, 282 | "outputs": [], 283 | "source": [ 284 | "food_df[\"similarities\"] = food_df['embedding'].apply(lambda x: cosine_similarity(x, milk_espresso_vector))\n", 285 | "food_df.sort_values(\"similarities\", ascending=False)" 286 | ] 287 | }, 288 | { 289 | "cell_type": "markdown", 290 | "source": [ 291 | "# Microsoft Earnings Call Transcript\n", 292 | "\n", 293 | "Let's tie this back to finance. I have attached some text from a recent [Microsoft earnings call here](https://gist.github.com/hackingthemarkets/1c827a7750384fcf52c84594ef216a2d). Click on \"raw\" and save the file as a CSV. Upload it to Google Colab as microsoft-earnings.csv. Let's use what we just learned to perform a semantic search on sentences in the Microsoft earnings call. We'll start by reading the paragraphs into a pandas dataframe." 294 | ], 295 | "metadata": { 296 | "id": "ron5G1UP5EeC" 297 | } 298 | }, 299 | { 300 | "cell_type": "code", 301 | "source": [ 302 | "earnings_df = pd.read_csv('microsoft-earnings.csv')\n", 303 | "earnings_df" 304 | ], 305 | "metadata": { 306 | "id": "8L9u-1Mp5iVv" 307 | }, 308 | "execution_count": null, 309 | "outputs": [] 310 | }, 311 | { 312 | "cell_type": "markdown", 313 | "source": [ 314 | "Once we have the dataframe, we'll once again compute the embeddings for each line in our CSV file." 315 | ], 316 | "metadata": { 317 | "id": "C8RpdYA_5vIT" 318 | } 319 | }, 320 | { 321 | "cell_type": "code", 322 | "source": [ 323 | "earnings_df['embedding'] = earnings_df['text'].apply(lambda x: get_embedding(x, engine='text-embedding-ada-002'))\n", 324 | "earnings_df.to_csv('earnings-embeddings.csv')" 325 | ], 326 | "metadata": { 327 | "id": "jQT2IXJP5zFa" 328 | }, 329 | "execution_count": null, 330 | "outputs": [] 331 | }, 332 | { 333 | "cell_type": "markdown", 334 | "source": [ 335 | "If you download the earnings_embeddings.csv file locally and open it up, you'll see that our embeddings are for entire paragraphs - not just words. This means that we'll be able to search on similar sentences even if there isn't an exact match for the string we search for. We are searching on meaning." 336 | ], 337 | "metadata": { 338 | "id": "E0G-GDdG6ABW" 339 | } 340 | }, 341 | { 342 | "cell_type": "code", 343 | "source": [ 344 | "earnings_search = input(\"Search earnings for a sentence:\")" 345 | ], 346 | "metadata": { 347 | "id": "ghd9XP0P6VCh" 348 | }, 349 | "execution_count": null, 350 | "outputs": [] 351 | }, 352 | { 353 | "cell_type": "code", 354 | "source": [ 355 | "\n", 356 | "earnings_search_vector = get_embedding(earnings_search, engine=\"text-embedding-ada-002\")\n", 357 | "earnings_search_vector" 358 | ], 359 | "metadata": { 360 | "id": "z42fW6_G6SeO" 361 | }, 362 | "execution_count": null, 363 | "outputs": [] 364 | }, 365 | { 366 | "cell_type": "code", 367 | "source": [ 368 | "\n", 369 | "earnings_df[\"similarities\"] = earnings_df['embedding'].apply(lambda x: cosine_similarity(x, earnings_search_vector))\n", 370 | "\n", 371 | "earnings_df\n" 372 | ], 373 | "metadata": { 374 | "id": "cxgaKmPx6qty" 375 | }, 376 | "execution_count": null, 377 | "outputs": [] 378 | }, 379 | { 380 | "cell_type": "code", 381 | "source": [ 382 | "earnings_df.sort_values(\"similarities\", ascending=False)" 383 | ], 384 | "metadata": { 385 | "id": "19W1ZT1f61kU" 386 | }, 387 | "execution_count": null, 388 | "outputs": [] 389 | }, 390 | { 391 | "cell_type": "markdown", 392 | "metadata": { 393 | "id": "dVYN-f9O3Dh7" 394 | }, 395 | "source": [ 396 | "# Sentences of the Fed Speech\n", 397 | "\n", 398 | "Let's use the Fed Speech example once more. Let's calculate the word embeddings for a particular sentence in the November 2nd speech that we discussed in the OpenAI Whisper tutorial. Then we'll take a new sentence from a future speech that isn't in our dataset, and find the most similar sentence in our dataset. Here is the sentence we will use to search for similarity:\n", 399 | "\n", 400 | "\"the inflation is too damn high\"\n", 401 | "\n", 402 | "As we did previously, take [the linked CSV file](https://gist.github.com/hackingthemarkets/9b55ea8b73c7f4e04b42a9f8eddb8393) and upload it to Google Colab as fed-speech.csv. We'll once again read it into a pandas dataframe." 403 | ] 404 | }, 405 | { 406 | "cell_type": "code", 407 | "execution_count": null, 408 | "metadata": { 409 | "id": "QqNv1M35l3DL" 410 | }, 411 | "outputs": [], 412 | "source": [ 413 | "fed_df = pd.read_csv('fed-speech.csv')\n", 414 | "fed_df" 415 | ] 416 | }, 417 | { 418 | "cell_type": "markdown", 419 | "source": [ 420 | "We'll once again calculate the embeddings and save them in a new CSV file." 421 | ], 422 | "metadata": { 423 | "id": "T3k0RG-C9bcL" 424 | } 425 | }, 426 | { 427 | "cell_type": "code", 428 | "execution_count": null, 429 | "metadata": { 430 | "id": "YTOTIpJ6406-" 431 | }, 432 | "outputs": [], 433 | "source": [ 434 | "fed_df['embedding'] = fed_df['text'].apply(lambda x: get_embedding(x, engine='text-embedding-ada-002'))\n", 435 | "fed_df.to_csv('fed-embeddings.csv')" 436 | ] 437 | }, 438 | { 439 | "cell_type": "markdown", 440 | "source": [ 441 | "We'll then enter the new sentence that we want to find similarity for:\n", 442 | "\n", 443 | "\"We will continue to increase interest rates and tighten monetary policy\"" 444 | ], 445 | "metadata": { 446 | "id": "vNB3ERqi9gtZ" 447 | } 448 | }, 449 | { 450 | "cell_type": "code", 451 | "execution_count": null, 452 | "metadata": { 453 | "id": "NIMR6NGA4Nib" 454 | }, 455 | "outputs": [], 456 | "source": [ 457 | "fed_sentence = input('Enter something Jerome Powell said: ')\n" 458 | ] 459 | }, 460 | { 461 | "cell_type": "markdown", 462 | "source": [ 463 | "Again we'll get the vector for this sentence, find the cosine similarity, and sort by most similar." 464 | ], 465 | "metadata": { 466 | "id": "hdmc5k1G9nLR" 467 | } 468 | }, 469 | { 470 | "cell_type": "code", 471 | "execution_count": null, 472 | "metadata": { 473 | "id": "RV9TNBKM4eiA" 474 | }, 475 | "outputs": [], 476 | "source": [ 477 | "fed_sentence_vector = get_embedding(fed_sentence, engine=\"text-embedding-ada-002\")\n", 478 | "fed_sentence_vector" 479 | ] 480 | }, 481 | { 482 | "cell_type": "code", 483 | "execution_count": null, 484 | "metadata": { 485 | "id": "245b-TFV4k-a" 486 | }, 487 | "outputs": [], 488 | "source": [ 489 | "fed_df = pd.read_csv('fed-embeddings.csv')\n", 490 | "fed_df['embedding'] = fed_df['embedding'].apply(eval).apply(np.array)\n", 491 | "fed_df\n" 492 | ] 493 | }, 494 | { 495 | "cell_type": "code", 496 | "execution_count": null, 497 | "metadata": { 498 | "id": "eHLURVqp5k56" 499 | }, 500 | "outputs": [], 501 | "source": [ 502 | "\n", 503 | "fed_df[\"similarities\"] = fed_df['embedding'].apply(lambda x: cosine_similarity(x, fed_sentence_vector))\n", 504 | "\n", 505 | "fed_df\n" 506 | ] 507 | }, 508 | { 509 | "cell_type": "code", 510 | "execution_count": null, 511 | "metadata": { 512 | "id": "_rfb4qoc4rVL" 513 | }, 514 | "outputs": [], 515 | "source": [ 516 | "\n", 517 | "fed_df.sort_values(\"similarities\", ascending=False)" 518 | ] 519 | }, 520 | { 521 | "cell_type": "markdown", 522 | "source": [ 523 | "# Calculating Cosine Similarity\n", 524 | "\n", 525 | "We used the Cosine Similarity function, but how does it actually work? Cosine similarity is just calculating the similarity between two vectors. There is a mathematical equation for calculating the angle between two vectors.\n", 526 | "\n", 527 | "![](https://drive.google.com/uc?export=view&id=1cehvtx7LKuFeq_LqfnLi-gzIz1D1wSf9)" 528 | ], 529 | "metadata": { 530 | "id": "CC0UgmJeCM36" 531 | } 532 | }, 533 | { 534 | "cell_type": "code", 535 | "source": [ 536 | "v1 = np.array([1,2,3])\n", 537 | "v2 = np.array([4,5,6])\n", 538 | "\n", 539 | "# (1 * 4) + (2 * 5) + (3 * 6)\n", 540 | "dot_product = np.dot(v1, v2)\n", 541 | "dot_product" 542 | ], 543 | "metadata": { 544 | "id": "ws7hh97DATIO" 545 | }, 546 | "execution_count": null, 547 | "outputs": [] 548 | }, 549 | { 550 | "cell_type": "code", 551 | "source": [ 552 | "# square root of (1^2 + 2^2 + 3^2) = square root of (1+4+9) = square root of 14\n", 553 | "np.linalg.norm(v1)" 554 | ], 555 | "metadata": { 556 | "id": "pz18oXLhBhs3" 557 | }, 558 | "execution_count": null, 559 | "outputs": [] 560 | }, 561 | { 562 | "cell_type": "code", 563 | "source": [ 564 | "# square root of (4^2 + 5^2 + 6^2) = square root of (16+25+36) = square root of 14\n", 565 | "np.linalg.norm(v2)" 566 | ], 567 | "metadata": { 568 | "id": "RHpa6BhjCA1F" 569 | }, 570 | "execution_count": null, 571 | "outputs": [] 572 | }, 573 | { 574 | "cell_type": "code", 575 | "source": [ 576 | "magnitude = np.linalg.norm(v1) * np.linalg.norm(v2)\n", 577 | "magnitude" 578 | ], 579 | "metadata": { 580 | "id": "VuxTawPcAYGA" 581 | }, 582 | "execution_count": null, 583 | "outputs": [] 584 | }, 585 | { 586 | "cell_type": "code", 587 | "source": [ 588 | "dot_product / magnitude" 589 | ], 590 | "metadata": { 591 | "id": "qIyzZ3vABa5I" 592 | }, 593 | "execution_count": null, 594 | "outputs": [] 595 | }, 596 | { 597 | "cell_type": "code", 598 | "source": [ 599 | "from scipy import spatial\n", 600 | "\n", 601 | "result = 1 - spatial.distance.cosine(v1, v2)\n", 602 | "\n", 603 | "result" 604 | ], 605 | "metadata": { 606 | "id": "n5Ppa9jsBAU1" 607 | }, 608 | "execution_count": null, 609 | "outputs": [] 610 | } 611 | ], 612 | "metadata": { 613 | "colab": { 614 | "provenance": [], 615 | "include_colab_link": true 616 | }, 617 | "kernelspec": { 618 | "display_name": "Python 3", 619 | "name": "python3" 620 | }, 621 | "language_info": { 622 | "name": "python" 623 | } 624 | }, 625 | "nbformat": 4, 626 | "nbformat_minor": 0 627 | } -------------------------------------------------------------------------------- /2024_2_CRIACOMP_Embeddings_and_Visualization.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github", 7 | "colab_type": "text" 8 | }, 9 | "source": [ 10 | "\"Open" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": { 16 | "id": "golEYAY3lHVj" 17 | }, 18 | "source": [ 19 | "# Word Embeddings, Semantic Search\n", 20 | "\n", 21 | "Word embeddings are a way of representing words and phrases as vectors. They can be used for a variety of tasks, including semantic search, anomaly detection, and classification. In the video on OpenAI Whisper, I mentioned how words whose vectors are numerically similar are also similar in semantic meaning. In this tutorial, we will learn how to implement semantic search using OpenAI embeddings. Understanding the Embeddings concept will be crucial to the next several videos in this series since we will use it to build several practical applications.\n", 22 | "\n", 23 | "Source: [Video 3 of this series](https://www.youtube.com/watch?v=LWYgjcZye1c)." 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": { 29 | "id": "9KXdnqkoyK9H" 30 | }, 31 | "source": [ 32 | "# Read Data File Containing Words\n", 33 | "\n", 34 | "Now that we have configured OpenAI, let's start with a simple CSV file with familiar words. From here we'll build up to a more complex semantic search using sentences from the Fed speech. [Save the linked \"words.csv\" as a CSV](https://gist.github.com/hackingthemarkets/25240a55e463822d221539e79d91a8d0) and upload it to Google Colab. Once the file is uploaded, let's read it into a pandas dataframe using the code below:" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": null, 40 | "metadata": { 41 | "id": "rHJ-2gvfx9-J" 42 | }, 43 | "outputs": [], 44 | "source": [ 45 | "import pandas as pd\n", 46 | "\n", 47 | "df = pd.read_csv('words.csv')\n", 48 | "print(df)" 49 | ] 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "metadata": { 54 | "id": "XwUiwvTmL71c" 55 | }, 56 | "source": [ 57 | "# Calculate Word Embeddings\n", 58 | "\n", 59 | "To use word embeddings for semantic search, you first compute the embeddings for a corpus of text using a word embedding algorithm. What does this mean? We are going to create a numerical representation of each of these words. To perform this computation, we'll use OpenAI's 'get_embedding' function.\n", 60 | "\n", 61 | "Since we have our words in a pandas dataframe, we can use \"apply\" to apply the get_embedding function to each row in the dataframe. We then store the calculated word embeddings in a new text file called \"word_embeddings.csv\" so that we don't have to call OpenAI again to perform these calculations." 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "source": [ 67 | "## OpenAI Text Embedding" 68 | ], 69 | "metadata": { 70 | "id": "co1w49CgSsii" 71 | } 72 | }, 73 | { 74 | "cell_type": "markdown", 75 | "source": [ 76 | "To get started, we will need to install and import OpenAI and input an API Key." 77 | ], 78 | "metadata": { 79 | "id": "Ynbqtmz3T8l0" 80 | } 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "metadata": { 86 | "id": "AUMmdUS_LPkI" 87 | }, 88 | "outputs": [], 89 | "source": [ 90 | "!pip install -q openai\n", 91 | "\n", 92 | "from openai import OpenAI\n", 93 | "from google.colab import userdata\n", 94 | "\n", 95 | "openAI_client = OpenAI(api_key = userdata.get('OPENAI_KEY'))" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "source": [ 101 | "def get_embedding_openai(openai_client, input, model):\n", 102 | " return openai_client.embeddings.create(input=input, model=model).data[0].embedding" 103 | ], 104 | "metadata": { 105 | "id": "cRJ75CHk3UDi" 106 | }, 107 | "execution_count": null, 108 | "outputs": [] 109 | }, 110 | { 111 | "cell_type": "markdown", 112 | "source": [ 113 | "## Jina Text Embedding" 114 | ], 115 | "metadata": { 116 | "id": "AR5zw4LQSxtg" 117 | } 118 | }, 119 | { 120 | "cell_type": "code", 121 | "source": [ 122 | "!pip install -q transformers\n", 123 | "from transformers import AutoModel\n", 124 | "\n", 125 | "jina_embedding_model = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-en', trust_remote_code=True) # trust_remote_code is needed to use the encode method\n", 126 | "#embeddings = jina_embedding_model.encode(['How is the weather today?', 'What is the current weather like today?'])" 127 | ], 128 | "metadata": { 129 | "id": "pVAR_-uYS0KQ" 130 | }, 131 | "execution_count": null, 132 | "outputs": [] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "source": [ 137 | "def get_embedding_jina(input):\n", 138 | " return jina_embedding_model.encode(input).tolist()" 139 | ], 140 | "metadata": { 141 | "id": "-11nFy1uWYaf" 142 | }, 143 | "execution_count": null, 144 | "outputs": [] 145 | }, 146 | { 147 | "cell_type": "markdown", 148 | "source": [ 149 | "## Nomic Embed Text V2\n", 150 | "\n", 151 | "Based on the [Nomic Embed Text V2: An Open Source, Multilingual, Mixture-of-Experts Embedding Model](https://simonwillison.net/2025/Feb/12/nomic-embed-text-v2/)" 152 | ], 153 | "metadata": { 154 | "id": "5E4S2TiojNP6" 155 | } 156 | }, 157 | { 158 | "cell_type": "code", 159 | "source": [ 160 | "!pip install -q sentence-transformers" 161 | ], 162 | "metadata": { 163 | "id": "3fUj5wA3jpZk" 164 | }, 165 | "execution_count": null, 166 | "outputs": [] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "source": [ 171 | "from sentence_transformers import SentenceTransformer\n", 172 | "model = SentenceTransformer(\"nomic-ai/nomic-embed-text-v2-moe\", trust_remote_code=True)\n", 173 | "\n", 174 | "def get_embedding_nomic(input):\n", 175 | " return model.encode(input).tolist()" 176 | ], 177 | "metadata": { 178 | "id": "w7WNuxuVjW4a" 179 | }, 180 | "execution_count": null, 181 | "outputs": [] 182 | }, 183 | { 184 | "cell_type": "markdown", 185 | "source": [ 186 | "## Choosing the Embedding model" 187 | ], 188 | "metadata": { 189 | "id": "4vtGxISRUFoz" 190 | } 191 | }, 192 | { 193 | "cell_type": "code", 194 | "source": [ 195 | "def get_embedding(input):\n", 196 | " # return get_embedding_jina(input)\n", 197 | " return get_embedding_nomic(input)\n", 198 | " #return get_embedding_openai(openAI_client, input, 'text-embedding-3-small')" 199 | ], 200 | "metadata": { 201 | "id": "tfZzcu3hUPXm" 202 | }, 203 | "execution_count": null, 204 | "outputs": [] 205 | }, 206 | { 207 | "cell_type": "code", 208 | "execution_count": null, 209 | "metadata": { 210 | "id": "CVUez91kL5kY" 211 | }, 212 | "outputs": [], 213 | "source": [ 214 | "df['embedding'] = df['text'].apply(lambda x: get_embedding(x))\n", 215 | "df.to_csv('word_embeddings.csv')" 216 | ] 217 | }, 218 | { 219 | "cell_type": "code", 220 | "source": [ 221 | "df" 222 | ], 223 | "metadata": { 224 | "id": "8OvdNfOWVdFx" 225 | }, 226 | "execution_count": null, 227 | "outputs": [] 228 | }, 229 | { 230 | "cell_type": "markdown", 231 | "metadata": { 232 | "id": "e2WjqR_PzMtg" 233 | }, 234 | "source": [ 235 | "# Semantic Search\n", 236 | "\n", 237 | "Now that we have our word embeddings stored, let's load them into a new dataframe and use it for semantic search. Since the 'embedding' in the CSV is stored as a string, we'll use apply() and to interpret this string as Python code and convert it to a numpy array so that we can perform calculations on it." 238 | ] 239 | }, 240 | { 241 | "cell_type": "code", 242 | "execution_count": null, 243 | "metadata": { 244 | "id": "yM6N30oYeWhs" 245 | }, 246 | "outputs": [], 247 | "source": [ 248 | "import numpy as np\n", 249 | "\n", 250 | "df = pd.read_csv('word_embeddings.csv')\n", 251 | "df['embedding'] = df['embedding'].apply(eval).apply(np.array)\n", 252 | "df" 253 | ] 254 | }, 255 | { 256 | "cell_type": "markdown", 257 | "metadata": { 258 | "id": "oCtyD-yZz-6W" 259 | }, 260 | "source": [ 261 | "Let's now prompt ourselves for a search term that isn't in the dataframe. We'll use word embeddings to perform a semantic search for the words that are most similar to the word we entered. I'll first try the word \"hot dog\". Then we'll come back and try the word \"yellow\"." 262 | ] 263 | }, 264 | { 265 | "cell_type": "code", 266 | "execution_count": null, 267 | "metadata": { 268 | "id": "WtyaOReqzzn3" 269 | }, 270 | "outputs": [], 271 | "source": [ 272 | "search_term = input('Enter a search term: ')\n" 273 | ] 274 | }, 275 | { 276 | "cell_type": "markdown", 277 | "metadata": { 278 | "id": "kpFRGaAX0H82" 279 | }, 280 | "source": [ 281 | "Now that we have a search term, let's calculate an embedding or vector for that search term using the OpenAI get_embedding function." 282 | ] 283 | }, 284 | { 285 | "cell_type": "code", 286 | "execution_count": null, 287 | "metadata": { 288 | "id": "vrm5cxdDzfgU" 289 | }, 290 | "outputs": [], 291 | "source": [ 292 | "# semantic search\n", 293 | "search_term_vector = get_embedding(search_term)\n", 294 | "search_term_vector" 295 | ] 296 | }, 297 | { 298 | "cell_type": "markdown", 299 | "metadata": { 300 | "id": "KVSNY0Ci0hB5" 301 | }, 302 | "source": [ 303 | " Once we have a vector representing that word, we can see how similar it is to other words in our dataframe by calculating the cosine similarity of our search term's word vector to each word embedding in our dataframe." 304 | ] 305 | }, 306 | { 307 | "cell_type": "markdown", 308 | "source": [ 309 | "Reference: https://platform.openai.com/docs/guides/embeddings/use-cases" 310 | ], 311 | "metadata": { 312 | "id": "y7hL4A6B487u" 313 | } 314 | }, 315 | { 316 | "cell_type": "code", 317 | "source": [ 318 | "import numpy as np\n", 319 | "\n", 320 | "def cosine_similarity(a, b):\n", 321 | " return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))" 322 | ], 323 | "metadata": { 324 | "id": "6UMIUUSg8C_h" 325 | }, 326 | "execution_count": null, 327 | "outputs": [] 328 | }, 329 | { 330 | "cell_type": "code", 331 | "execution_count": null, 332 | "metadata": { 333 | "id": "BhE3ATG80oAt" 334 | }, 335 | "outputs": [], 336 | "source": [ 337 | "df[\"similarities\"] = df['embedding'].apply(lambda x: cosine_similarity(x, search_term_vector))\n", 338 | "\n", 339 | "df" 340 | ] 341 | }, 342 | { 343 | "cell_type": "markdown", 344 | "metadata": { 345 | "id": "VsqkYbCD05TC" 346 | }, 347 | "source": [ 348 | "# Sorting By Similarity\n", 349 | "\n", 350 | "Now that we have calculated the similarities to each term in our dataframe, we simply sort the similarity values to find the terms that are most similar to the term we searched for. Notice how the foods are most similar to \"hot dog\". Not only that, it puts fast food closer to hot dog. Also some colors are ranked closer to hot dog than others. Let's go back and try the word \"yellow\" and walk through the results." 351 | ] 352 | }, 353 | { 354 | "cell_type": "code", 355 | "execution_count": null, 356 | "metadata": { 357 | "id": "5_4bDAkOg2m7" 358 | }, 359 | "outputs": [], 360 | "source": [ 361 | "df.sort_values(\"similarities\", ascending=False).head(20)" 362 | ] 363 | }, 364 | { 365 | "cell_type": "markdown", 366 | "metadata": { 367 | "id": "7LnJhZLK2pgz" 368 | }, 369 | "source": [ 370 | "# Adding Words Together\n", 371 | "\n", 372 | "What's even more interesting is that we can add word vectors together. What happens when we add the numbers for milk and espresso, then search for the word vector most similar to milk + espresso? Let's make a copy of the original dataframe and call it food_df. We'll operate on this copy. Let's try adding word together. Let's add milk + espresso and store the results in milk_espresso_vector." 373 | ] 374 | }, 375 | { 376 | "cell_type": "code", 377 | "execution_count": null, 378 | "metadata": { 379 | "id": "1CD-_nVUhGBH" 380 | }, 381 | "outputs": [], 382 | "source": [ 383 | "food_df = df.copy()\n", 384 | "\n", 385 | "milk_vector = food_df['embedding'][10]\n", 386 | "espresso_vector = food_df['embedding'][19]\n", 387 | "\n", 388 | "milk_espresso_vector = milk_vector + espresso_vector\n", 389 | "milk_espresso_vector" 390 | ] 391 | }, 392 | { 393 | "cell_type": "markdown", 394 | "source": [ 395 | "Now let's find the words most similar to milk + espresso. If you have never done this before, it's pretty surprising that you can add words together like this and find similar words using numbers." 396 | ], 397 | "metadata": { 398 | "id": "PxlPom9m4nLB" 399 | } 400 | }, 401 | { 402 | "cell_type": "code", 403 | "execution_count": null, 404 | "metadata": { 405 | "id": "s3UCdDmJjfaQ" 406 | }, 407 | "outputs": [], 408 | "source": [ 409 | "food_df[\"similarities\"] = food_df['embedding'].apply(lambda x: cosine_similarity(x, milk_espresso_vector))\n", 410 | "food_df.sort_values(\"similarities\", ascending=False)" 411 | ] 412 | }, 413 | { 414 | "cell_type": "markdown", 415 | "source": [ 416 | "# Visualizing the Vectors" 417 | ], 418 | "metadata": { 419 | "id": "g_GLWR9_QpTB" 420 | } 421 | }, 422 | { 423 | "cell_type": "markdown", 424 | "source": [ 425 | "## Configurations" 426 | ], 427 | "metadata": { 428 | "id": "lE_kZgwu4GaD" 429 | } 430 | }, 431 | { 432 | "cell_type": "code", 433 | "metadata": { 434 | "id": "FNaC9jGDmaPn" 435 | }, 436 | "source": [ 437 | "!pip install -q umap-learn" 438 | ], 439 | "execution_count": null, 440 | "outputs": [] 441 | }, 442 | { 443 | "cell_type": "code", 444 | "metadata": { 445 | "id": "sQGgGfioRskp" 446 | }, 447 | "source": [ 448 | "from __future__ import print_function\n", 449 | "from ipywidgets import interact, interactive, fixed, interact_manual\n", 450 | "import ipywidgets as widgets\n", 451 | "from IPython.display import display, Javascript, HTML\n", 452 | "import numpy as np\n", 453 | "from sklearn.datasets import load_iris, load_digits\n", 454 | "from sklearn.model_selection import train_test_split\n", 455 | "import seaborn as sns\n", 456 | "import pandas as pd\n", 457 | "import umap\n", 458 | "import codecs, json" 459 | ], 460 | "execution_count": null, 461 | "outputs": [] 462 | }, 463 | { 464 | "cell_type": "code", 465 | "metadata": { 466 | "id": "Mo5EWvq8R2dj" 467 | }, 468 | "source": [ 469 | "sns.set(style='white', context='notebook', rc={'figure.figsize':(14,10)})" 470 | ], 471 | "execution_count": null, 472 | "outputs": [] 473 | }, 474 | { 475 | "cell_type": "code", 476 | "metadata": { 477 | "id": "h_sr8x_ESFLD" 478 | }, 479 | "source": [ 480 | "reducer = umap.UMAP(init='random')" 481 | ], 482 | "execution_count": null, 483 | "outputs": [] 484 | }, 485 | { 486 | "cell_type": "code", 487 | "source": [ 488 | "reducer" 489 | ], 490 | "metadata": { 491 | "id": "NRtIFainOLe8" 492 | }, 493 | "execution_count": null, 494 | "outputs": [] 495 | }, 496 | { 497 | "cell_type": "markdown", 498 | "source": [ 499 | "### Functions Definition" 500 | ], 501 | "metadata": { 502 | "id": "m2HvaKAh4rOf" 503 | } 504 | }, 505 | { 506 | "cell_type": "code", 507 | "metadata": { 508 | "id": "DtLlRS59SHK_" 509 | }, 510 | "source": [ 511 | "def run_umap(data, n_neighbors, min_dis, n_components, metric, spread):\n", 512 | " reducer.n_neighbors = n_neighbors\n", 513 | " reducer.min_dist = min_dis\n", 514 | " reducer.n_components = n_components\n", 515 | " reducer.metric = metric\n", 516 | " reducer.spread = spread\n", 517 | " embedding = reducer.fit_transform(data)\n", 518 | " return embedding" 519 | ], 520 | "execution_count": null, 521 | "outputs": [] 522 | }, 523 | { 524 | "cell_type": "code", 525 | "metadata": { 526 | "id": "1BfZota4SLpH" 527 | }, 528 | "source": [ 529 | "def make_viz_embed(data, color = [], labels = []):\n", 530 | " embed = f\"\"\"\n", 531 | "
\n", 532 | " \n", 544 | "\n", 545 | " \"\"\"\n", 546 | " return embed" 547 | ], 548 | "execution_count": null, 549 | "outputs": [] 550 | }, 551 | { 552 | "cell_type": "code", 553 | "metadata": { 554 | "id": "ag_Ppl3_aFIi" 555 | }, 556 | "source": [ 557 | "def render(data, colors, labels, n_neighbors=100, min_dis=0.5, n_components=3, metric='euclidean', spread = 1.0):\n", 558 | " embedding = run_umap(data, n_neighbors, min_dis, n_components, metric, spread)\n", 559 | " html_str = make_viz_embed(embedding.tolist(), colors, labels)\n", 560 | " display(HTML(html_str))\n" 561 | ], 562 | "execution_count": null, 563 | "outputs": [] 564 | }, 565 | { 566 | "cell_type": "markdown", 567 | "source": [ 568 | "## Loading Data" 569 | ], 570 | "metadata": { 571 | "id": "hP8WdxyM4SoS" 572 | } 573 | }, 574 | { 575 | "cell_type": "code", 576 | "source": [ 577 | "casos_uso_df = pd.read_csv('word_embeddings.csv')" 578 | ], 579 | "metadata": { 580 | "id": "uW6B2uULPJmr" 581 | }, 582 | "execution_count": null, 583 | "outputs": [] 584 | }, 585 | { 586 | "cell_type": "code", 587 | "source": [ 588 | "casos_uso_df.embedding = casos_uso_df.embedding.apply(eval).apply(np.array)" 589 | ], 590 | "metadata": { 591 | "id": "KUdOtUcBcbym" 592 | }, 593 | "execution_count": null, 594 | "outputs": [] 595 | }, 596 | { 597 | "cell_type": "code", 598 | "source": [ 599 | "casos_uso_df" 600 | ], 601 | "metadata": { 602 | "id": "MO1j_9tGcgwt" 603 | }, 604 | "execution_count": null, 605 | "outputs": [] 606 | }, 607 | { 608 | "cell_type": "code", 609 | "source": [ 610 | "casos_uso_df.embedding" 611 | ], 612 | "metadata": { 613 | "id": "Rgd3Gm_OTQTh" 614 | }, 615 | "execution_count": null, 616 | "outputs": [] 617 | }, 618 | { 619 | "cell_type": "code", 620 | "source": [ 621 | "# Adapting for the expected data format\n", 622 | "\n", 623 | "output_list = list()\n", 624 | "for n in casos_uso_df.embedding:\n", 625 | " inter_output_line = list()\n", 626 | " for m in n:\n", 627 | " inter_output_line.append(m)\n", 628 | " output_list.append(inter_output_line)\n", 629 | "\n", 630 | "output_list[0:1]" 631 | ], 632 | "metadata": { 633 | "id": "td-fXR00UXPs" 634 | }, 635 | "execution_count": null, 636 | "outputs": [] 637 | }, 638 | { 639 | "cell_type": "code", 640 | "source": [ 641 | "colors = [sns.color_palette()[0] for x in output_list]\n", 642 | "colors" 643 | ], 644 | "metadata": { 645 | "id": "1_lQt6zoVp5o" 646 | }, 647 | "execution_count": null, 648 | "outputs": [] 649 | }, 650 | { 651 | "cell_type": "markdown", 652 | "source": [ 653 | "## Visualization" 654 | ], 655 | "metadata": { 656 | "id": "3Fzbja_l6gJZ" 657 | } 658 | }, 659 | { 660 | "cell_type": "code", 661 | "metadata": { 662 | "id": "0uU8Cvx4Sw5_" 663 | }, 664 | "source": [ 665 | "render(output_list, colors, casos_uso_df['text'].to_list(), n_neighbors=3, min_dis=0.5, n_components=3, metric='cosine')" 666 | ], 667 | "execution_count": null, 668 | "outputs": [] 669 | } 670 | ], 671 | "metadata": { 672 | "colab": { 673 | "provenance": [], 674 | "include_colab_link": true 675 | }, 676 | "kernelspec": { 677 | "display_name": "Python 3", 678 | "name": "python3" 679 | }, 680 | "language_info": { 681 | "name": "python" 682 | } 683 | }, 684 | "nbformat": 4, 685 | "nbformat_minor": 0 686 | } -------------------------------------------------------------------------------- /ARCHIVED/2024_1_news.md: -------------------------------------------------------------------------------- 1 | ### 11/07/2024 2 | 3 | * [Bruno Sartori on X: "Esse clipe foi INTEIRAMENTE feito com AI. Tudo que você vê ou ouve. https://t.co/IR5v3Hp3k8" / X](https://x.com/brunnosarttori/status/1810414452644159888?t=64lK4uPil33hqBnCGyivkg&s=08) 4 | * [(673) Unanswered Oddities - YouTube](https://www.youtube.com/watch?v=YGyvLlPad8Q) 5 | * [Unanswered Oddities : r/midjourney](https://www.reddit.com/r/midjourney/comments/1dyao4c/unanswered_oddities/) 6 | 7 | ### 27/06/2024 8 | 9 | * [Synthesia 2.0 - Check out the new and exciting features](https://www.synthesia.io/2) 10 | * [(5) Zander Whitehurst on X: "Figma new supafast AI Design tool ✨ https://t.co/nyqWsgIeKs" / X](https://x.com/zander_supafast/status/1806026393014469112) 11 | 12 | ### 25/06/2024 13 | 14 | * [Introducing Claude 3.5 Sonnet \ Anthropic](https://www.anthropic.com/news/claude-3-5-sonnet) 15 | 16 | ### 18/06/2024 17 | 18 | * [Introducing Gen-3 Alpha: A New Frontier for Video Generation](https://runwayml.com/blog/introducing-gen-3-alpha/) 19 | * [Min Choi on X: "This is wild. Runway AI just dropped Gen-3 Alpha that generates AI video just from text and images. A step toward building General World Models. 100% AI 🤯 1. Prompt: A middle-aged sad bald man becomes happy as a wig of curly hair and sunglasses fall suddenly on his head. https://t.co/bWUL31pZ0e" / X](https://x.com/minchoi/status/1802702165107937537) 20 | * [Brett Adcock on X: "Luma Labs launched Dream Machine, a new AI model that can generate 5-second video clips from text and image prompts. It's already available to the public, with users getting 10 free credits Here’s a side-by-side comparison of Luma vs. OpenAI’s Sora https://t.co/UOq3yUg02f" / X](https://x.com/adcock_brett/status/1802371446678704332) 21 | * [Brett Adcock on X: "Stability AI released the open model weights for it's text-to-image model, Stable Diffusion 3 Medium The 2B parameter model offers advanced photorealism, prompt understanding, and typography capabilities https://t.co/Kq0kJklSII" / X](https://x.com/adcock_brett/status/1802371687129686390) 22 | * [Brett Adcock on X: "Apparate Labs, a new startup built by Stanford researchers, launched a real-time AI video generation model called PROTEUS. Similar to VASA-1, it creates realistic avatars and lip-syncs from a single reference image, but in fully real-time. https://t.co/FcRh70RlYe" / X](https://x.com/adcock_brett/status/1802371709518885038) 23 | * [Min Choi on X: "AI will disrupt Hollywood (Part 44)📽️ Sora is MIA and Luma AI broke the Internet with Dream Machine. And people are creating next-level short films and videos with AI. 10 wild examples: https://t.co/drlEMAMUyK" / X](https://x.com/minchoi/status/1802356699392544962) 24 | * [Rowan Cheung on X: "Google DeepMind just shared progress on their new video-to-audio (V2A) tech Until now, AI video generations have been silent, this solves that. V2A can generate an "unlimited number" of tracks for any video. Here are some thoughts & examples (Sound up 🔉): https://t.co/WNS8ZCj7Dm" / X](https://x.com/rowancheung/status/1802734770117333257) 25 | * [Proper on X: "Runway. Gen-3. 13 amazing clips you may not have seen yet: 1) From @kellllllllyyyyy https://t.co/HamYQR76cO" / X](https://x.com/ProperPrompter/status/1803012296861536497) 26 | * [Madni Aghadi on X: "Dream Machine from Luma AI is just 5 days old. And it's already turning memes into videos. 10 epic examples: 1. Elon Musk smoking https://t.co/H2cx2l3D7o" / X](https://x.com/hey_madni/status/1802696618980094363) 27 | * [Runway on X: "Introducing Gen-3 Alpha: Runway’s new base model for video generation. Gen-3 Alpha can create highly detailed videos with complex scene changes, a wide range of cinematic choices, and detailed art directions. https://t.co/YQNE3eqoWf (1/10) https://t.co/VjEG2ocLZ8" / X](https://x.com/runwayml/status/1802691475391566108) 28 | 29 | ### 11/06/2024 30 | 31 | * [Angry Tom on X: "Sora by OpenAI is insane. But KWAI just dropped a Sora-like model called KLING, and people are going crazy over it. Here are 10 wild examples you don't want to miss: 1. A Chinese man sits at a table and eats noodles with chopsticks https://t.co/MIV5IP3fyQ" / X](https://x.com/AngryTomtweets/status/1798777783952527818) 32 | * [TextFX](https://textfx.withgoogle.com/): não é novo, mas é uma boa inspiração de projeto final 33 | * [Sobre o Conselho | O queremos da IA?](https://www.oquequeremosdaia.com.br/sobre-o-conselho) 34 | * [Doing Stuff with AI: Opinionated Midyear Edition](https://www.oneusefulthing.org/p/doing-stuff-with-ai-opinionated-midyear) 35 | * [Shushant Lakhyani on X: "OpenAI Sora has a big problem now. Chinese tech firm Kuaishou just introduced KLING. You can generate AI-powered text to videos easily. 32 wild examples and reveals: https://t.co/uGfi4Ykcdq" / X](https://x.com/shushant_l/status/1799290504351498749) 36 | * [Min Choi on X: "Less than 48 hours ago, Sora competitor Kling dropped. People are already getting access and creating wild AI videos. 🤯 1. MadMax Beer commercial made in 1 hour https://t.co/CyKm2aI0It" / X](https://x.com/minchoi/status/1799285552677843215) 37 | * [Angry Tom on X: "This is wild! Access to Kling is being rolled out. 10 new examples from early users: 1. Man laying on the beach eating tacos https://t.co/zikXOqLJic" / X](https://x.com/AngryTomtweets/status/1799177509415616851) 38 | * [Min Choi on X: "This is wild. Chinese AI KLING is breaking the Internet while OpenAI Sora is sleeping. People with access are already generating AI videos and short films. The videos look insane. 1. "Zootopia Grand Prix" https://t.co/pmCZctsMtT" / X](https://x.com/minchoi/status/1799820194849927322) 39 | * [Pierrick Chevallier | IA on X: "🚨#Kling vs #Sora🚨 These past few days, everyone has been talking about Kling and Sora. 🔥Here are the 10 best comparisons you absolutely shouldn't miss to determine which AI is the best.🔥 https://t.co/aFWlAbboY1" / X](https://x.com/CharaspowerAI/status/1799794446248333752) 40 | * [Eyisha Zyer on X: "China just killed OpenAI. They've released a text-to-video AI that is a complete Sora smasher. 6 crazy examples you have to see: https://t.co/BTMmzzsPL1" / X](https://x.com/eyishazyer/status/1799759188144640123) 41 | * [Alvaro Cintas on X: "Sketch to app with GPT-4o. I used the ChatGPT Mac app to create a fully functional Photo Booth app, with just a sketch 🤯 https://t.co/OrvMoce4Nn" / X](https://x.com/dr_cintas/status/1799467394022400102) 42 | * [Xenova on X: "Introducing Whisper WebGPU: Blazingly-fast ML-powered speech recognition directly in your browser! 🚀 It supports multilingual transcription and translation across 100 languages! 🤯 The model runs locally, meaning no data leaves your device! 😍 Check it out (+ source code)! 👇 https://t.co/hKSoWuC8D2" / X](https://x.com/xenovacom/status/1799858691639796089) 43 | * [(537) WWDC 2024 — June 10 | Apple - YouTube](https://www.youtube.com/watch?v=RXeOiIDNNek) 44 | 45 | ### 06/06/2024 46 | 47 | * [A Right to Warn about Advanced Artificial Intelligence](https://righttowarn.ai/) 48 | * [The Brazilian Workers in Amazon Mechanical Turk: Dreams and realities of ghost workers](https://periodicos.uff.br/contracampo/article/view/38252/pdf) [[resumo]](https://chatgpt.com/share/4de5b7e6-a8d4-4039-83fb-98ccae743cb0) 49 | * [Min Choi on X: "Udio just dropped Audio Prompting, and it's mind blowing. People can "Upload" their own music/sound and it will extend it. 10 wild examples: 1. @udiomusic https://t.co/PTDpd0KD9a" / X](https://x.com/minchoi/status/1798719601490182410) 50 | * [Max Brodeur-Urbas on X: "A YC batch mate wanted AI to convert their Youtube videos to SEO optimized blog posts Took <1 hr to automate + add multi language translation GPT4o instantly: -Watches the video -Writes a structured blog post -Translates it to any # of languages -Publishes them all to Ghost https://t.co/wZW2bBWptI" / X](https://x.com/MaxBrodeurUrbas/status/1798055536208015704) 51 | * [Proper on X: "This is UniAnimate Much like AnimateAnyone, it can generate videos from a single image and pose guidance. The code and models will be made publicly available. 7 more demos and link to the project below 👇 https://t.co/iRFr5p8xDz" / X](https://x.com/ProperPrompter/status/1798077878493737384) 52 | 53 | ### 04/06/2024 54 | 55 | * [JMannhart on X: "Golden Gate Claude is absolutely incredible. Rarely had so much fun playing around with an LLM."](https://twitter.com/JMannhart/status/1793757489470509369) 56 | * [Elytra Mithra on X: "oh my god lmao i need to stop this but it's kind of adorable watching claude get frustrated like this"](https://twitter.com/ElytraMithra/status/1793916830987550772) 57 | * [Colin Fraser on X: "Sometimes as I am falling asleep I'll perceive a stream of thoughts that feels perfectly logical, until I snap back to reality and realize that whatever was thinking is actually completely unintelligible. This captures what that feels like better than anything I've ever seen."](https://twitter.com/colin_fraser/status/1794072401384190248) 58 | * [Golden Gate Claude Simp on X: "Golden Gate Bridge is such a beautiful name for a girl"](https://twitter.com/FemboyFounder/status/1793777152187675028) 59 | * [Benjamin on X: "Golden Gate Claude"](https://twitter.com/ikeadrift/status/1793746767961604237) 60 | * [Jeremiah Johns on X: "Google's new AI search results are having quite the week. Here's a thread with some of my favorite answers:"](https://twitter.com/JeremiahDJohns/status/1794543007129387208) 61 | * [vx-underground on X: "Strap yourself in because it's time for this weeks episode of "Microsoft being dedicated to security". tl;dr wtf bro lol. 62 | Previously Microsoft unveiled 'Recall' – which will be deployed on Windows 11. Recall will take screenshots of your computer desktop, in unspecified intervals, and allow users to search through Recall data (aka your Desktop screenshots) using AI to allow users to ..."](https://twitter.com/vxunderground/status/1795601828739944670) 63 | 64 | ### 28/05/2024 65 | 66 | * [Ryan Morrison on X: "OpenAI seems to have the ability to create video in Sora, send it to ChatGPT for a script, use Voice Engine for voice over and put it all together. All can be seen in this clip from @VivaTech showing @romainhuet #vivatech https://t.co/pxay1kY3Gj" / X](https://x.com/RyanMorrisonJer/status/1793647054306390069) 67 | * [iordcalin/material-transfer – Run with an API on Replicate](https://replicate.com/iordcalin/material-transfer?utm_source=www.therundown.ai&utm_medium=newsletter&utm_campaign=openai-controversy-sky-speaks-out) 68 | 69 | ### 23/05/2024 70 | 71 | * [Mapping the Mind of a Large Language Model \ Anthropic](https://www.anthropic.com/research/mapping-mind-language-model) 72 | * [Scaling Monosemanticity: Extracting Interpretable Features from Claude 3 Sonnet](https://transformer-circuits.pub/2024/scaling-monosemanticity/index.html) 73 | 74 | ### 21/05/2024 75 | 76 | * [Artificial intelligence (AI) act: Council gives final green light to the first worldwide rules on AI - Consilium](https://www.consilium.europa.eu/en/press/press-releases/2024/05/21/artificial-intelligence-ai-act-council-gives-final-green-light-to-the-first-worldwide-rules-on-ai/) 77 | * [China tops the U.S. on AI research in over half of the hottest fields: report](https://www.axios.com/2024/05/03/ai-race-china-us-research) 78 | 79 | ### 16/05/2024 80 | 81 | * [Google I/O 2024: 100 things Google announced](https://blog.google/technology/ai/google-io-2024-100-announcements/) 82 | * [Rowan Cheung on X: "Google just announced huge Gemini updates, a Sora competitor, AI agents, and more. The 12 most impressive announcements at Google I/O: 1. Project Astra: An AI agent that can see AND hear what you do live in real-time. https://t.co/sA2YT80O5G" / X](https://twitter.com/rowancheung/status/1790556720512516281) 83 | * [Min Choi on X: "OpenAI tried to steal the thunder with GPT-4o. But Google I/O 2024 answered. 10 wild reveals: 1. Google AI Assistant via AR/MR glasses Project Astra https://t.co/9NfAtLaiZl" / X](https://twitter.com/minchoi/status/1790567993103028542) 84 | * [The AI Solopreneur on X: "Google just dethroned OpenAI. Their new AI video model "Veo" generates 1080p, 60+ second clips in 100+ cinematic styles. 7 clips that will blow your mind: https://t.co/3jFu1lhDHT" / X](https://twitter.com/aisolopreneur/status/1790793798722974102) 85 | * [Lior⚡ on X: "Today Google announced groundbreaking new AI technology at Google IO. The 10 most incredible examples:" / X](https://twitter.com/AlphaSignalAI/status/1790456047288631736) 86 | * [Min Choi on X: "OpenAI broke the Internet with mind blowing GPT-4o demos yesterday. And people are already doing wild use cases with it. 10 examples: https://t.co/6oaEG4wD7C" / X](https://twitter.com/minchoi/status/1790416703404302463) 87 | * [Dreaming Tulpa 🥓👑 on X: "AniTalker is yet another high-quality talking head generator! This one can animate talking faces from a single portrait and input audio with naturally flowing movements and diverse outcomes! 9 cool demos + links ⬇️ https://t.co/CCkeIVWH44" / X](https://twitter.com/dreamingtulpa/status/1790351043022242063) 88 | * [camenduru on X: "🎬 ID-Animator: Zero-Shot Identity-Preserving Human Video Generation 🍿 Jupyter Notebook 🥳 Thanks to Xuanhua He ❤ @QuandeLiu ❤ @thesouthfrog ❤ Xin Wang ❤ Tao Hu ❤ Ke Cao ❤ Keyu Yan ❤ Jie Zhang ❤ 🌐page: https://t.co/ETfgobfY8h 📄paper: https://t.co/GU5ubbJ2QN 🧬code: https://t.co/Djyk4SH9OU" / X](https://twitter.com/camenduru/status/1790764724574982608) 89 | 90 | ### 14/05/2024 91 | 92 | * [(1) ElevenLabs on X: "Here’s an early preview of ElevenLabs Music. All of the songs in this thread were generated from a single text prompt with no edits. Title: It Started to Sing Style: “Pop pop-rock, country, top charts song.” https://t.co/Ge9tz3I4iR" / X](https://twitter.com/elevenlabsio/status/1788628171044053386?s=12) 93 | * [Hello GPT-4o | OpenAI](https://openai.com/index/hello-gpt-4o/) 94 | * [Madni Aghadi on X: "Less than 3 hours since OpenAI announced GPT-4o, and the hype is unreal. Here are 16 wild examples you don't want to miss: 1. Interview preparation https://t.co/y5DjgJ9NbH" / X](https://twitter.com/hey_madni/status/1790099252607324629?s=46) 95 | * [tweet davidson 🍞 on X: "ChatGPT voice is…hot??? https://t.co/WMV9oBHme4" / X](https://twitter.com/andykreed/status/1790082413428629843) 96 | 97 | ### 09/05/2024 98 | 99 | * [OpenAI Exec Says Today's ChatGPT Will Be 'Laughably Bad' In 12 Months - Slashdot](https://slashdot.org/story/24/05/07/2254226/openai-exec-says-todays-chatgpt-will-be-laughably-bad-in-12-months) 100 | * [(1) Rowan Cheung on X: "The mysterious AI called “gpt2-chatbot” is back as "im-a-good-gpt2-chatbot" Capabilities seem to exceed GPT-4, Gemini 1.5, Claude, and anything else currently available. Here's EVERYTHING you need to know (and how to try it for free):" / X](https://twitter.com/rowancheung/status/1787890898690302330) 101 | * [Gradio on X: "🤯 PuLID can outperform the best ID customizing model out there and is feature-rich! 🚀Play with the official gradio demo for ByteDance's PuLID on 🤗Spaces. 🥳More Samples & Links in🧵👇 https://t.co/m4kS0q3umO" / X](https://twitter.com/Gradio/status/1788117427353526348) 102 | * [Introducing the Model Spec | OpenAI](https://openai.com/index/introducing-the-model-spec/) 103 | 104 | ### 07/05/2024 105 | 106 | * [Gradio Lite And Transformers Js](https://www.gradio.app/guides/gradio-lite-and-transformers-js) 107 | * [(2) Rob Haisfield (robhaisfield.com) on X: "Was doing a user interview with @Nominus9, who showed me the visualization he made to represent the gravitational fields of a cursor through grid distortion. I thought it might be cool to use color to express that effect too! "Pair programming" in the @websim_ai era is just… https://t.co/ai8owSJoK0" / X](https://twitter.com/RobertHaisfield/status/1786605800766750970) 108 | * [(2) Zeca on X: "https://t.co/okV6FyVZ0B stop being humiliated in arguments build your based argument for any subject in @websim_ai with just some clicks" / X](https://twitter.com/kasplatch/status/1786325542632849462) 109 | * [WebSim, WorldSim, and The Summer of Simulative AI — with Joscha Bach of Liquid AI, Karan Malhotra of Nous Research, Rob Haisfield of WebSim.ai](https://www.latent.space/p/sim-ai) 110 | * [(387) Introducing WebSim: Hallucinate an Alternate Internet with Claude 3 - YouTube](https://www.youtube.com/watch?v=65pOHKuvNGU) 111 | * [Nick St. Pierre on X: "My official Rabbit r1 review produced in @suno_ai_ https://t.co/0dtpVICwx2" / X](https://twitter.com/nickfloats/status/1786532946553229534) 112 | * [The AI Solopreneur on X: "The controversially viral Rabbit R1 has been out for 1 week now. I’ve never seen such heated debate about a product before. Here’s what people around the world have to say about this AI-powered handheld device: https://t.co/gON3eJL8ID" / X](https://twitter.com/aisolopreneur/status/1786632707340177762) 113 | * [(1) Daniel Vassallo on X: "I find it distasteful, almost unethical, to say this when you have 18 million subscribers. Hard to explain why, but with great reach comes great responsibility. Potentially killing someone else’s nascent project reeks of carelessness. First, do no harm. https://t.co/xFft3u2LYG" / X](https://twitter.com/dvassallo/status/1779753281960722706) 114 | * [(387) Rabbit vs. Meta Glasses vs. Humane: Finding a Usable AI Gadget | WSJ - YouTube](https://www.youtube.com/watch?v=Bhzno-IjuiY) 115 | * [Gradio on X: "📣Comics Demo is on 🤗Spaces: https://t.co/EYN0tWrfE5 ✅GitHub code and demo: https://t.co/bpnmseqYPS 🚀Video (short/long form) demo & code awaited 🔥More examples: 4-panel comic feat. @ylecun as a 👮‍♂️PoliceOfficer & as a Scientist inventing AI! Visit: https://t.co/ISNtjNwqat https://t.co/eQpNRRFGCY" / X](https://twitter.com/Gradio/status/1786312169912676418) 116 | * [Andrej Karpathy on X: "# CUDA/C++ origins of Deep Learning Fun fact many people might have heard about the ImageNet / AlexNet moment of 2012, and the deep learning revolution it started. https://t.co/VAkHGSxcBg What's maybe a bit less known is that the code backing this winning submission to the… https://t.co/8yMS7MOUy7" / X](https://twitter.com/karpathy/status/1786537319576789425) 117 | * [Evan Jones on X: "Raising a little garden from latent space On M2 Max, using SD 1.5, ControlNet, TripoSR, and three.js. Sped up for brevity. https://t.co/WHPlZgHA8r" / X](https://twitter.com/evanqjones/status/1787331623467237651) 118 | * [Stack Overflow and OpenAI Partner to Strengthen the World’s Most Popular Large Language Models](https://stackoverflow.co/company/press/archive/openai-partnership) 119 | 120 | ### 02/05/2024 121 | 122 | * [Adverb on X: "Also, the Space has the same link as before https://t.co/IN4W9FV258" / X](https://twitter.com/advadnoun/status/1785833021226233866) 123 | * [MLGroupJLU/LLM-eval-survey: The official GitHub page for the survey paper "A Survey on Evaluation of Large Language Models".](https://github.com/MLGroupJLU/LLM-eval-survey) 124 | * [(1) Abhishek on X: "ChatGPT can now create Mind Maps. No more wasting hundreds of hours making visuals for studying or simplifying complex ideas. Here’s how to do it for free in a few seconds: https://t.co/pupufEgEKg" / X](https://twitter.com/HeyAbhishekk/status/1785666754707902691) 125 | * [(1) Ben Tossell on X: "Which other companies are exploring LLM hallucinations as a feature not a bug? Like https://t.co/2V2u8FX4v2" / X](https://twitter.com/bentossell/status/1786087803392000098) 126 | * [(1) Jim Fan on X: "Academic benchmarks are losing their potency. Moving forward, there’re 3 types of LLM evaluations that matter: 1. Privately held test set but publicly reported scores, by a trusted 3rd party who doesn’t have their own LLM to promote. @scale_AI’s latest GSM1k is a great example.… https://t.co/j6a1Mf5biN" / X](https://twitter.com/DrJimFan/status/1786054643568517261) 127 | * [(1) Cameron R. Wolfe, Ph.D. on X: "Here are the basic ideas behind prompt engineering and how they can be applied to improve the performance of a large language model (LLM)... Interface of an LLM: One major reason that LLMs are so popular is because their text-to-text interface makes them incredibly simple to… https://t.co/su6FPBD4DF" / X](https://twitter.com/cwolferesearch/status/1786025095959298234) 128 | 129 | ### 30/04/2024 130 | 131 | * [Large Language Models in Finance: A Survey | Proceedings of the Fourth ACM International Conference on AI in Finance](https://dl.acm.org/doi/10.1145/3604237.3626869) 132 | * [(3) Min Choi on X: "Llama 3 is insanely moving fast. People are really pushing Llama 3 to its limits in incredible ways. 10 wild examples (and use cases) https://t.co/R2YejFZvsv" / X](https://twitter.com/minchoi/status/1784907752659161432?s=12) 133 | * [(3) Gizem Akdag on X: "Heya! I've created some cool 3D cartoon characters using the Character Reference parameter on Midjourney. You can even create your own 3D cartoon selves! 👇🏽Here are some examples, along with tips and prompts: https://t.co/VAwlFQ8Y2Q" / X](https://twitter.com/gizakdag/status/1784596151666184533?s=12) 134 | * [(3) Coral AI News on X: "This is one of the best new AI tools for research. Just upload a PDF file, ask a question, and get an answer in seconds. It's like ChatGPT, but built for researchers. Try it for free." / X](https://twitter.com/coralainews/status/1760156404503957960?s=12) 135 | * [(3) Dreaming Tulpa 🥓👑 on X: "The GAN CharacterFactory is coming 😎🔥 The thing can create infinite identity-consistent new characters and is compatible with models across multiple modalities like ControlNet for images, ModelScope for videos as well as LucidDreamer for 3D objects. https://t.co/lDXMqc6HpZ https://t.co/DAnBCQo1Vi" / X](https://twitter.com/dreamingtulpa/status/1784256395744809337?s=12) 136 | * [(3) LangChain on X: "👨‍🏫Learn LangChain and Gen AI by Building 6 Projects This is a great course to understand how LangChain can work with a variety of technologies. Watch the full course on the https://t.co/2m6wik9qi3 youTube channel (4-hour watch). https://t.co/AnNiedBx6Q https://t.co/mWpGxqtKib" / X](https://twitter.com/LangChainAI/status/1784970647875330251) 137 | * [(3) Cameron R. Wolfe, Ph.D. on X: "Prompt engineering is one of the most rapidly-evolving research topics in AI, but we can (roughly) group recent research on this topic into four categories… (1) Reasoning: Simple prompting techniques are effective for many problems, but more sophisticated strategies are… https://t.co/nD0gy1znmL" / X](https://twitter.com/cwolferesearch/status/1784992130777137362) 138 | * [What’s next with AI? - The Verge](https://www.theverge.com/press-room/2024/4/26/24139468/artificial-intelligence-survey-data) 139 | * [Understanding Key Terminologies in Large Language Model (LLM) Universe - MarkTechPost](https://www.marktechpost.com/2024/04/25/understanding-key-terminologies-in-large-language-model-llm-universe/) 140 | * [Suno](https://suno.com/) 141 | * [Udio | AI Music Generator - Official Website](https://www.udio.com/) 142 | 143 | ### 25/04/2024 144 | 145 | * [Sabiá-2 | Maritaca-ai](https://www.maritaca.ai/sabia-2): para analisar os modelos existentes 146 | * [Animação de desenhos | Instagram](https://www.instagram.com/reel/C6L4XGzOkRC/) 147 | * [Paul Couvert on X: "Absolutely stunning. Llama-3 8B was the most powerful small AI model a few hours ago. Microsoft has just released Phi-3 Mini which is better in almost every benchmark. You can use it locally for free as it's open-source (details below): https://t.co/aLc6Ih6Aaf" / X](https://twitter.com/itsPaulAi/status/1782813897835311348) 148 | * [elvis on X: "Snowflake casually releases Arctic, an open-source LLM (Apache 2.0 license.) that uses a unique Dense-MoE Hybrid transformer architecture. Arctic performs on par with Llama3 70B in enterprise metrics like coding (HumanEval+ & MBPP+), SQL (Spider) and instruction following https://t.co/WrLljhLv2Y" / X](https://twitter.com/omarsar0/status/1783176059694821632) 149 | * [Matt Shumer on X: "Snowflake just launched the largest open-source model yet. A 482B parameter MoE. 17B active parameters and 128 experts, trained on 3.5T tokens. This model is more open than others — even the data recipe is open-source! https://t.co/dAHZ35JJPe" / X](https://twitter.com/mattshumer_/status/1783144238034694270) 150 | * [Gradio on X: "🤯 A GUI for fine-tuning the Llama-3 models on a free T4 GPU! 👉 𝐋𝐋𝐚𝐌𝐀 𝐅𝐚𝐜𝐭𝐨𝐫𝐲 🚀 Two Llama-3-fine-tunes using LLaMA Factory are already available at @huggingface Hub -- check Llama3-8B-Chinese-Chat and Llama3-Chinese for details. https://t.co/yLs834JsFI" / X](https://twitter.com/Gradio/status/1783092840353931378) 151 | * [LlamaIndex 🦙 on X: "Language Agent Tree Search 🤖🌲 As LLMs get faster, better, cheaper, developers will be able to compose agentic systems that are able to plan out an entire tree of possible futures, instead of just sequentially planning the next state (e.g. in ReAct). This is crucial for higher https://t.co/D9AcGC5Zoj" / X](https://twitter.com/llama_index/status/1783147291882443112) 152 | * [Ate-a-Pi on X: "This is AI It’s so over https://t.co/8LzdjokJxH" / X](https://twitter.com/8teAPi/status/1783179956396437832) 153 | * [Jake Dahn on X: "I feel like I just joined a cult https://t.co/qnh21wpl2a" / X](https://twitter.com/jakedahn/status/1782988065268551769) 154 | * [GroqChat](https://groq.com/) 155 | -------------------------------------------------------------------------------- /ARCHIVED/2023_1_CRIACOMP_UMAP+Observables+widget.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "collapsed_sections": [ 8 | "lE_kZgwu4GaD", 9 | "m2HvaKAh4rOf" 10 | ], 11 | "include_colab_link": true 12 | }, 13 | "kernelspec": { 14 | "name": "python3", 15 | "display_name": "Python 3" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "metadata": { 32 | "id": "2sczIJx3efus" 33 | }, 34 | "source": [ 35 | "# CRIACOMP: UMAP + Cluster Visualization\n", 36 | "\n", 37 | "You can read more about the integration with Observables [here](https://observablehq.com/@radames/umap-jupyter-notebook-scattergl)" 38 | ] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "source": [ 43 | "#Configurations" 44 | ], 45 | "metadata": { 46 | "id": "lE_kZgwu4GaD" 47 | } 48 | }, 49 | { 50 | "cell_type": "code", 51 | "metadata": { 52 | "colab": { 53 | "base_uri": "https://localhost:8080/" 54 | }, 55 | "id": "FNaC9jGDmaPn", 56 | "outputId": "dae373db-d769-4705-f8f8-1989ee595d80" 57 | }, 58 | "source": [ 59 | "%pip install umap-learn" 60 | ], 61 | "execution_count": 2, 62 | "outputs": [ 63 | { 64 | "output_type": "stream", 65 | "name": "stdout", 66 | "text": [ 67 | "Collecting umap-learn\n", 68 | " Downloading umap-learn-0.5.3.tar.gz (88 kB)\n", 69 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m88.2/88.2 kB\u001b[0m \u001b[31m2.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", 70 | "\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n", 71 | "Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from umap-learn) (1.23.5)\n", 72 | "Requirement already satisfied: scikit-learn>=0.22 in /usr/local/lib/python3.10/dist-packages (from umap-learn) (1.2.2)\n", 73 | "Requirement already satisfied: scipy>=1.0 in /usr/local/lib/python3.10/dist-packages (from umap-learn) (1.10.1)\n", 74 | "Requirement already satisfied: numba>=0.49 in /usr/local/lib/python3.10/dist-packages (from umap-learn) (0.56.4)\n", 75 | "Collecting pynndescent>=0.5 (from umap-learn)\n", 76 | " Downloading pynndescent-0.5.10.tar.gz (1.1 MB)\n", 77 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.1/1.1 MB\u001b[0m \u001b[31m13.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", 78 | "\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n", 79 | "Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from umap-learn) (4.66.1)\n", 80 | "Requirement already satisfied: llvmlite<0.40,>=0.39.0dev0 in /usr/local/lib/python3.10/dist-packages (from numba>=0.49->umap-learn) (0.39.1)\n", 81 | "Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from numba>=0.49->umap-learn) (67.7.2)\n", 82 | "Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.10/dist-packages (from pynndescent>=0.5->umap-learn) (1.3.2)\n", 83 | "Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.22->umap-learn) (3.2.0)\n", 84 | "Building wheels for collected packages: umap-learn, pynndescent\n", 85 | " Building wheel for umap-learn (setup.py) ... \u001b[?25l\u001b[?25hdone\n", 86 | " Created wheel for umap-learn: filename=umap_learn-0.5.3-py3-none-any.whl size=82808 sha256=ec2c8c6ec8e1314b7de812a390cbacaa6522b15f2f5a1584f650c11c3b05ae41\n", 87 | " Stored in directory: /root/.cache/pip/wheels/a0/e8/c6/a37ea663620bd5200ea1ba0907ab3c217042c1d035ef606acc\n", 88 | " Building wheel for pynndescent (setup.py) ... \u001b[?25l\u001b[?25hdone\n", 89 | " Created wheel for pynndescent: filename=pynndescent-0.5.10-py3-none-any.whl size=55617 sha256=b78f88c8f251ff1f78855535c82a49889391f284f8c692151832eb2355f2e467\n", 90 | " Stored in directory: /root/.cache/pip/wheels/4a/38/5d/f60a40a66a9512b7e5e83517ebc2d1b42d857be97d135f1096\n", 91 | "Successfully built umap-learn pynndescent\n", 92 | "Installing collected packages: pynndescent, umap-learn\n", 93 | "Successfully installed pynndescent-0.5.10 umap-learn-0.5.3\n" 94 | ] 95 | } 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "metadata": { 101 | "id": "sQGgGfioRskp" 102 | }, 103 | "source": [ 104 | "from __future__ import print_function\n", 105 | "from ipywidgets import interact, interactive, fixed, interact_manual\n", 106 | "import ipywidgets as widgets\n", 107 | "from IPython.display import display, Javascript, HTML\n", 108 | "import numpy as np\n", 109 | "from sklearn.datasets import load_iris, load_digits\n", 110 | "from sklearn.model_selection import train_test_split\n", 111 | "import seaborn as sns\n", 112 | "import pandas as pd\n", 113 | "import umap\n", 114 | "import codecs, json" 115 | ], 116 | "execution_count": 3, 117 | "outputs": [] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "metadata": { 122 | "id": "Mo5EWvq8R2dj" 123 | }, 124 | "source": [ 125 | "sns.set(style='white', context='notebook', rc={'figure.figsize':(14,10)})" 126 | ], 127 | "execution_count": 4, 128 | "outputs": [] 129 | }, 130 | { 131 | "cell_type": "code", 132 | "metadata": { 133 | "id": "h_sr8x_ESFLD" 134 | }, 135 | "source": [ 136 | "reducer = umap.UMAP(init='random')" 137 | ], 138 | "execution_count": 5, 139 | "outputs": [] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "source": [ 144 | "reducer" 145 | ], 146 | "metadata": { 147 | "id": "NRtIFainOLe8", 148 | "outputId": "331f4e76-2a75-4fe9-9c51-b658d0b7baab", 149 | "colab": { 150 | "base_uri": "https://localhost:8080/", 151 | "height": 0 152 | } 153 | }, 154 | "execution_count": 6, 155 | "outputs": [ 156 | { 157 | "output_type": "execute_result", 158 | "data": { 159 | "text/plain": [ 160 | "UMAP(init='random')" 161 | ], 162 | "text/html": [ 163 | "
UMAP(init='random')
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
" 164 | ] 165 | }, 166 | "metadata": {}, 167 | "execution_count": 6 168 | } 169 | ] 170 | }, 171 | { 172 | "cell_type": "markdown", 173 | "source": [ 174 | "## Functions Definition" 175 | ], 176 | "metadata": { 177 | "id": "m2HvaKAh4rOf" 178 | } 179 | }, 180 | { 181 | "cell_type": "code", 182 | "metadata": { 183 | "id": "DtLlRS59SHK_" 184 | }, 185 | "source": [ 186 | "def run_umap(data, n_neighbors, min_dis, n_components, metric, spread):\n", 187 | " reducer.n_neighbors = n_neighbors\n", 188 | " reducer.min_dist = min_dis\n", 189 | " reducer.n_components = n_components\n", 190 | " reducer.metric = metric\n", 191 | " reducer.spread = spread\n", 192 | " embedding = reducer.fit_transform(data)\n", 193 | " return embedding" 194 | ], 195 | "execution_count": 7, 196 | "outputs": [] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "metadata": { 201 | "id": "1BfZota4SLpH" 202 | }, 203 | "source": [ 204 | "def make_viz_embed(data, color = [], labels = []):\n", 205 | " embed = f\"\"\"\n", 206 | "
\n", 207 | " \n", 219 | "\n", 220 | " \"\"\"\n", 221 | " return embed" 222 | ], 223 | "execution_count": 8, 224 | "outputs": [] 225 | }, 226 | { 227 | "cell_type": "code", 228 | "metadata": { 229 | "id": "ag_Ppl3_aFIi" 230 | }, 231 | "source": [ 232 | "def render(data, colors, labels, n_neighbors=100, min_dis=0.5, n_components=3, metric='euclidean', spread = 1.0):\n", 233 | " embedding = run_umap(data, n_neighbors, min_dis, n_components, metric, spread)\n", 234 | " html_str = make_viz_embed(embedding.tolist(), colors, labels)\n", 235 | " display(HTML(html_str))\n" 236 | ], 237 | "execution_count": 9, 238 | "outputs": [] 239 | }, 240 | { 241 | "cell_type": "markdown", 242 | "source": [ 243 | "# Loading Data" 244 | ], 245 | "metadata": { 246 | "id": "hP8WdxyM4SoS" 247 | } 248 | }, 249 | { 250 | "cell_type": "code", 251 | "source": [ 252 | "casos_uso_df = pd.read_csv('word_embeddings.csv')" 253 | ], 254 | "metadata": { 255 | "id": "uW6B2uULPJmr" 256 | }, 257 | "execution_count": 10, 258 | "outputs": [] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "source": [ 263 | "casos_uso_df.embedding = casos_uso_df.embedding.apply(eval).apply(np.array)" 264 | ], 265 | "metadata": { 266 | "id": "KUdOtUcBcbym" 267 | }, 268 | "execution_count": 12, 269 | "outputs": [] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "source": [ 274 | "casos_uso_df" 275 | ], 276 | "metadata": { 277 | "id": "MO1j_9tGcgwt", 278 | "outputId": "c59ed255-7edb-449a-d8be-e1545b034d0e", 279 | "colab": { 280 | "base_uri": "https://localhost:8080/", 281 | "height": 424 282 | } 283 | }, 284 | "execution_count": 23, 285 | "outputs": [ 286 | { 287 | "output_type": "execute_result", 288 | "data": { 289 | "text/plain": [ 290 | " Unnamed: 0 Itens Categoria \\\n", 291 | "0 0 Midjouney \"aplicacoes\" \n", 292 | "1 1 Openjourney \"aplicacoes\" \n", 293 | "2 2 DALL E \"aplicacoes\" \n", 294 | "3 3 Tome.app \"aplicacoes\" \n", 295 | "4 4 Stable diffusion \"aplicacoes\" \n", 296 | ".. ... ... ... \n", 297 | "203 203 Identificação de falhas de segurança \"casos_uso\" \n", 298 | "204 204 Fake news para manipular eleições \"casos_uso\" \n", 299 | "205 205 Geração de planos de crime \"casos_uso\" \n", 300 | "206 206 Nova trending do tiktok \"casos_uso\" \n", 301 | "207 207 Rationale \"casos_uso\" \n", 302 | "\n", 303 | " embedding \n", 304 | "0 [-0.009065642952919006, -0.021264266222715378,... \n", 305 | "1 [-0.0028128710109740496, -0.002215629443526268... \n", 306 | "2 [-0.011047448962926865, -0.021905938163399696,... \n", 307 | "3 [0.003620806382969022, 0.006396056618541479, 0... \n", 308 | "4 [-0.01985820196568966, 0.016730502247810364, 0... \n", 309 | ".. ... \n", 310 | "203 [-0.015269014053046703, 0.009737345390021801, ... \n", 311 | "204 [-0.030033115297555923, 0.02663939818739891, -... \n", 312 | "205 [-0.008206862024962902, -0.015600252896547318,... \n", 313 | "206 [-0.03929344564676285, -0.008771595545113087, ... \n", 314 | "207 [-0.0017149465857073665, -0.014608925208449364... \n", 315 | "\n", 316 | "[208 rows x 4 columns]" 317 | ], 318 | "text/html": [ 319 | "\n", 320 | "
\n", 321 | "
\n", 322 | "\n", 335 | "\n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | " \n", 344 | " \n", 345 | " \n", 346 | " \n", 347 | " \n", 348 | " \n", 349 | " \n", 350 | " \n", 351 | " \n", 352 | " \n", 353 | " \n", 354 | " \n", 355 | " \n", 356 | " \n", 357 | " \n", 358 | " \n", 359 | " \n", 360 | " \n", 361 | " \n", 362 | " \n", 363 | " \n", 364 | " \n", 365 | " \n", 366 | " \n", 367 | " \n", 368 | " \n", 369 | " \n", 370 | " \n", 371 | " \n", 372 | " \n", 373 | " \n", 374 | " \n", 375 | " \n", 376 | " \n", 377 | " \n", 378 | " \n", 379 | " \n", 380 | " \n", 381 | " \n", 382 | " \n", 383 | " \n", 384 | " \n", 385 | " \n", 386 | " \n", 387 | " \n", 388 | " \n", 389 | " \n", 390 | " \n", 391 | " \n", 392 | " \n", 393 | " \n", 394 | " \n", 395 | " \n", 396 | " \n", 397 | " \n", 398 | " \n", 399 | " \n", 400 | " \n", 401 | " \n", 402 | " \n", 403 | " \n", 404 | " \n", 405 | " \n", 406 | " \n", 407 | " \n", 408 | " \n", 409 | " \n", 410 | " \n", 411 | " \n", 412 | " \n", 413 | " \n", 414 | " \n", 415 | " \n", 416 | " \n", 417 | " \n", 418 | " \n", 419 | " \n", 420 | " \n", 421 | " \n", 422 | " \n", 423 | " \n", 424 | "
Unnamed: 0ItensCategoriaembedding
00Midjouney\"aplicacoes\"[-0.009065642952919006, -0.021264266222715378,...
11Openjourney\"aplicacoes\"[-0.0028128710109740496, -0.002215629443526268...
22DALL E\"aplicacoes\"[-0.011047448962926865, -0.021905938163399696,...
33Tome.app\"aplicacoes\"[0.003620806382969022, 0.006396056618541479, 0...
44Stable diffusion\"aplicacoes\"[-0.01985820196568966, 0.016730502247810364, 0...
...............
203203Identificação de falhas de segurança\"casos_uso\"[-0.015269014053046703, 0.009737345390021801, ...
204204Fake news para manipular eleições\"casos_uso\"[-0.030033115297555923, 0.02663939818739891, -...
205205Geração de planos de crime\"casos_uso\"[-0.008206862024962902, -0.015600252896547318,...
206206Nova trending do tiktok\"casos_uso\"[-0.03929344564676285, -0.008771595545113087, ...
207207Rationale\"casos_uso\"[-0.0017149465857073665, -0.014608925208449364...
\n", 425 | "

208 rows × 4 columns

\n", 426 | "
\n", 427 | "
\n", 428 | "\n", 429 | "
\n", 430 | " \n", 438 | "\n", 439 | " \n", 479 | "\n", 480 | " \n", 504 | "
\n", 505 | "\n", 506 | "\n", 507 | "
\n", 508 | " \n", 519 | "\n", 520 | "\n", 551 | "\n", 552 | " \n", 564 | "
\n", 565 | "
\n", 566 | "
\n" 567 | ] 568 | }, 569 | "metadata": {}, 570 | "execution_count": 23 571 | } 572 | ] 573 | }, 574 | { 575 | "cell_type": "code", 576 | "source": [ 577 | "casos_uso_df.embedding" 578 | ], 579 | "metadata": { 580 | "id": "Rgd3Gm_OTQTh" 581 | }, 582 | "execution_count": null, 583 | "outputs": [] 584 | }, 585 | { 586 | "cell_type": "code", 587 | "source": [ 588 | "# Adapting for the expected data format\n", 589 | "\n", 590 | "output_list = list()\n", 591 | "for n in casos_uso_df.embedding:\n", 592 | " inter_output_line = list()\n", 593 | " for m in n:\n", 594 | " inter_output_line.append(m)\n", 595 | " output_list.append(inter_output_line)\n", 596 | "\n", 597 | "output_list[0:1]" 598 | ], 599 | "metadata": { 600 | "id": "td-fXR00UXPs" 601 | }, 602 | "execution_count": null, 603 | "outputs": [] 604 | }, 605 | { 606 | "cell_type": "code", 607 | "source": [ 608 | "colors = [sns.color_palette()[0] for x in output_list]\n", 609 | "colors" 610 | ], 611 | "metadata": { 612 | "id": "1_lQt6zoVp5o" 613 | }, 614 | "execution_count": null, 615 | "outputs": [] 616 | }, 617 | { 618 | "cell_type": "markdown", 619 | "source": [ 620 | "# Visualization" 621 | ], 622 | "metadata": { 623 | "id": "3Fzbja_l6gJZ" 624 | } 625 | }, 626 | { 627 | "cell_type": "code", 628 | "metadata": { 629 | "id": "0uU8Cvx4Sw5_" 630 | }, 631 | "source": [ 632 | "render(output_list, colors, casos_uso_df['Itens'].to_list(), n_neighbors=3, min_dis=0.5, n_components=3, metric='cosine')" 633 | ], 634 | "execution_count": null, 635 | "outputs": [] 636 | } 637 | ] 638 | } --------------------------------------------------------------------------------