repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | { |
| #2 | "cells": [ |
| #3 | { |
| #4 | "cell_type": "markdown", |
| #5 | "metadata": { |
| #6 | "id": "b02n_zJ_hl3d" |
| #7 | }, |
| #8 | "source": [ |
| #9 | "## Cookbook for using Hugging Face Hub with Embedchain" |
| #10 | ] |
| #11 | }, |
| #12 | { |
| #13 | "cell_type": "markdown", |
| #14 | "metadata": { |
| #15 | "id": "gyJ6ui2vhtMY" |
| #16 | }, |
| #17 | "source": [ |
| #18 | "### Step-1: Install embedchain package" |
| #19 | ] |
| #20 | }, |
| #21 | { |
| #22 | "cell_type": "code", |
| #23 | "execution_count": null, |
| #24 | "metadata": { |
| #25 | "colab": { |
| #26 | "base_uri": "https://localhost:8080/", |
| #27 | "height": 1000 |
| #28 | }, |
| #29 | "id": "-NbXjAdlh0vJ", |
| #30 | "outputId": "35ddc904-8067-44cf-dcc9-3c8b4cd29989" |
| #31 | }, |
| #32 | "outputs": [], |
| #33 | "source": [ |
| #34 | "!pip install embedchain[huggingface_hub,opensource]" |
| #35 | ] |
| #36 | }, |
| #37 | { |
| #38 | "cell_type": "markdown", |
| #39 | "metadata": { |
| #40 | "id": "nGnpSYAAh2bQ" |
| #41 | }, |
| #42 | "source": [ |
| #43 | "### Step-2: Set Hugging Face Hub related environment variables\n", |
| #44 | "\n", |
| #45 | "You can find your `HUGGINGFACE_ACCESS_TOKEN` key on your [Hugging Face Hub dashboard](https://huggingface.co/settings/tokens)" |
| #46 | ] |
| #47 | }, |
| #48 | { |
| #49 | "cell_type": "code", |
| #50 | "execution_count": null, |
| #51 | "metadata": { |
| #52 | "id": "0fBdQ9GAiRvK" |
| #53 | }, |
| #54 | "outputs": [], |
| #55 | "source": [ |
| #56 | "import os\n", |
| #57 | "from embedchain import App\n", |
| #58 | "\n", |
| #59 | "os.environ[\"HUGGINGFACE_ACCESS_TOKEN\"] = \"hf_xxx\"" |
| #60 | ] |
| #61 | }, |
| #62 | { |
| #63 | "cell_type": "markdown", |
| #64 | "metadata": { |
| #65 | "id": "PGt6uPLIi1CS" |
| #66 | }, |
| #67 | "source": [ |
| #68 | "### Step-3 Create embedchain app and define your config" |
| #69 | ] |
| #70 | }, |
| #71 | { |
| #72 | "cell_type": "code", |
| #73 | "execution_count": null, |
| #74 | "metadata": { |
| #75 | "id": "Amzxk3m-i3tD" |
| #76 | }, |
| #77 | "outputs": [], |
| #78 | "source": [ |
| #79 | "app = App.from_config(config={\n", |
| #80 | " \"llm\": {\n", |
| #81 | " \"provider\": \"huggingface\",\n", |
| #82 | " \"config\": {\n", |
| #83 | " \"model\": \"google/flan-t5-xxl\",\n", |
| #84 | " \"temperature\": 0.5,\n", |
| #85 | " \"max_tokens\": 1000,\n", |
| #86 | " \"top_p\": 0.8,\n", |
| #87 | " \"stream\": False\n", |
| #88 | " }\n", |
| #89 | " },\n", |
| #90 | " \"embedder\": {\n", |
| #91 | " \"provider\": \"huggingface\",\n", |
| #92 | " \"config\": {\n", |
| #93 | " \"model\": \"sentence-transformers/all-mpnet-base-v2\"\n", |
| #94 | " }\n", |
| #95 | " }\n", |
| #96 | "})" |
| #97 | ] |
| #98 | }, |
| #99 | { |
| #100 | "cell_type": "markdown", |
| #101 | "metadata": { |
| #102 | "id": "XNXv4yZwi7ef" |
| #103 | }, |
| #104 | "source": [ |
| #105 | "### Step-4: Add data sources to your app" |
| #106 | ] |
| #107 | }, |
| #108 | { |
| #109 | "cell_type": "code", |
| #110 | "execution_count": null, |
| #111 | "metadata": { |
| #112 | "colab": { |
| #113 | "base_uri": "https://localhost:8080/", |
| #114 | "height": 70 |
| #115 | }, |
| #116 | "id": "Sn_0rx9QjIY9", |
| #117 | "outputId": "3c2a803a-3a93-4b0d-a6ae-17ae3c96c3c2" |
| #118 | }, |
| #119 | "outputs": [], |
| #120 | "source": [ |
| #121 | "app.add(\"https://www.forbes.com/profile/elon-musk\")" |
| #122 | ] |
| #123 | }, |
| #124 | { |
| #125 | "cell_type": "markdown", |
| #126 | "metadata": { |
| #127 | "id": "_7W6fDeAjMAP" |
| #128 | }, |
| #129 | "source": [ |
| #130 | "### Step-5: All set. Now start asking questions related to your data" |
| #131 | ] |
| #132 | }, |
| #133 | { |
| #134 | "cell_type": "code", |
| #135 | "execution_count": null, |
| #136 | "metadata": { |
| #137 | "colab": { |
| #138 | "base_uri": "https://localhost:8080/" |
| #139 | }, |
| #140 | "id": "cvIK7dWRjN_f", |
| #141 | "outputId": "47a89d1c-b322-495c-822a-6c2ecef894d2" |
| #142 | }, |
| #143 | "outputs": [], |
| #144 | "source": [ |
| #145 | "while(True):\n", |
| #146 | " question = input(\"Enter question: \")\n", |
| #147 | " if question in ['q', 'exit', 'quit']:\n", |
| #148 | " break\n", |
| #149 | " answer = app.query(question)\n", |
| #150 | " print(answer)" |
| #151 | ] |
| #152 | } |
| #153 | ], |
| #154 | "metadata": { |
| #155 | "colab": { |
| #156 | "provenance": [] |
| #157 | }, |
| #158 | "kernelspec": { |
| #159 | "display_name": "Python 3", |
| #160 | "name": "python3" |
| #161 | }, |
| #162 | "language_info": { |
| #163 | "name": "python" |
| #164 | } |
| #165 | }, |
| #166 | "nbformat": 4, |
| #167 | "nbformat_minor": 0 |
| #168 | } |
| #169 |