Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopoli authored May 10, 2024
1 parent 51f05f7 commit 4aafb3c
Showing 1 changed file with 9 additions and 187 deletions.
196 changes: 9 additions & 187 deletions use_examples/Llamaindex_LangChain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,42 +89,6 @@
"!pip install llama-index"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "S5zGEdBxsujM",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "S5zGEdBxsujM",
"outputId": "ee9b54d8-e114-447a-da8c-9f9efc95bb62"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" _| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_|\n",
" _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|\n",
" _|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_|\n",
" _| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|\n",
" _| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_|\n",
"\n",
" To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .\n",
"Token: \n",
"Add token as git credential? (Y/n) n\n",
"Token is valid (permission: read).\n",
"Your token has been saved to /root/.cache/huggingface/token\n",
"Login successful\n"
]
}
],
"source": [
"!huggingface-cli login"
]
},
{
"cell_type": "markdown",
"id": "4HENF0YqJhLB",
Expand Down Expand Up @@ -336,7 +300,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "JG9WQUtLFCqv",
"metadata": {
"colab": {
Expand All @@ -359,49 +323,14 @@
"id": "JG9WQUtLFCqv",
"outputId": "1cc079af-e0e8-46aa-e0c7-8f227ba4d6ee"
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_token.py:89: UserWarning: \n",
"The secret `HF_TOKEN` does not exist in your Colab secrets.\n",
"To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.\n",
"You will be able to reuse this secret in all of your notebooks.\n",
"Please note that authentication is recommended but still optional to access public models or datasets.\n",
" warnings.warn(\n",
"The `load_in_4bit` and `load_in_8bit` arguments are deprecated and will be removed in the future versions. Please, pass a `BitsAndBytesConfig` object in `quantization_config` argument instead.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "65f4ebb79b3d419a927211270de9eb4f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Loading checkpoint shards: 0%| | 0/7 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n"
]
}
],
"outputs": [],
"source": [
"import torch\n",
"from llama_index.llms.huggingface import HuggingFaceLLM\n",
"from llama_index.core import PromptTemplate\n",
"\n",
"# Model names (make sure you have access on HF)\n",
"LLAMA3_7B = \"m-polignano-uniba/LLaMAntino-3-ANITA-8B-Inst-DPO-ITA\"\n",
"LLAMA3_7B = \"swap-uniba/LLaMAntino-3-ANITA-8B-Inst-DPO-ITA\"\n",
"selected_model = LLAMA3_7B\n",
"\n",
"query_wrapper_prompt = PromptTemplate(\n",
Expand Down Expand Up @@ -484,7 +413,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "182fa3c7-5e64-46ca-8cd6-28d11abbe84c",
"metadata": {
"colab": {
Expand Down Expand Up @@ -529,92 +458,7 @@
"id": "182fa3c7-5e64-46ca-8cd6-28d11abbe84c",
"outputId": "7e110371-e830-408e-d501-9e1f5433179a"
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2a10ec65cf124e5786363d89bd674722",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Parsing nodes: 0%| | 0/3 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7e2b45dc54a24791baacc4ca65b3e12d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Summarizing documents: 0%| | 0/3 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"current doc id: 14531\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/lib/python3.10/dist-packages/transformers/generation/configuration_utils.py:500: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0.0` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`.\n",
" warnings.warn(\n",
"Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.\n",
"/usr/local/lib/python3.10/dist-packages/bitsandbytes/nn/modules.py:426: UserWarning: Input type into Linear4bit is torch.float16, but bnb_4bit_compute_dtype=torch.float32 (default). This will lead to slow inference or training speed.\n",
" warnings.warn(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"current doc id: 188171\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/lib/python3.10/dist-packages/transformers/generation/configuration_utils.py:500: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0.0` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`.\n",
" warnings.warn(\n",
"Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.\n",
"Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"current doc id: 11867\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "45a1137289434f73807b434d7dcf8e5f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Generating embeddings: 0%| | 0/3 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"from llama_index.core.indices.document_summary import DocumentSummaryIndex\n",
"from llama_index.core.node_parser import SentenceSplitter\n",
Expand Down Expand Up @@ -870,7 +714,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"id": "bV3JsId72B3g",
"metadata": {
"colab": {
Expand All @@ -893,32 +737,10 @@
"id": "bV3JsId72B3g",
"outputId": "e03d966d-9b76-4b63-a752-431698db6120"
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "43408164871c4a5eba75592f460136fd",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Loading checkpoint shards: 0%| | 0/7 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"tokenizer = AutoTokenizer.from_pretrained(\"m-polignano-uniba/LLaMAntino-3-ANITA_test\")\n",
"model = AutoModelForCausalLM.from_pretrained(\"m-polignano-uniba/LLaMAntino-3-ANITA_test\", quantization_config = bnb_config,device_map={\"\":0})"
"tokenizer = AutoTokenizer.from_pretrained(\"swap-uniba/LLaMAntino-3-ANITA_test\")\n",
"model = AutoModelForCausalLM.from_pretrained(\"swap-uniba/LLaMAntino-3-ANITA_test\", quantization_config = bnb_config,device_map={\"\":0})"
]
},
{
Expand Down

0 comments on commit 4aafb3c

Please sign in to comment.