File size: 2,364 Bytes
6d80262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f2a1f6a4-7f00-4fe5-8fdc-eb49aae1850b",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/romainfouilland/code/envs/iamu2/lib/python3.9/site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020\n",
      "  warnings.warn(\n",
      "/Users/romainfouilland/code/envs/iamu2/lib/python3.9/site-packages/huggingface_hub/utils/_deprecation.py:131: FutureWarning: 'InferenceApi' (from 'huggingface_hub.inference_api') is deprecated and will be removed from version '1.0'. `InferenceApi` client is deprecated in favor of the more feature-complete `InferenceClient`. Check out this guide to learn how to convert your script to use it: https://huggingface.co./docs/huggingface_hub/guides/inference#legacy-inferenceapi-client.\n",
      "  warnings.warn(warning_message, FutureWarning)\n"
     ]
    }
   ],
   "source": [
    "from langchain import PromptTemplate, HuggingFaceHub, LLMChain\n",
    "\n",
    "# Ref.: https://python.langchain.com/docs/integrations/llms/huggingface_hub\n",
    "repos = [\n",
    "    # \"google/flan-t5-xxl\",\n",
    "    \"databricks/dolly-v2-3b\",\n",
    "]\n",
    "template = \"\"\"Question : {question}\n",
    "\n",
    "Réponse : \"\"\"\n",
    "prompt = PromptTemplate(template=template, input_variables=[\"question\"])\n",
    "llm=HuggingFaceHub(repo_id=repos[0], model_kwargs={\"temperature\": 1e-10, \"max_length\": 248})\n",
    "question = \"Qu'est-ce qu'un SAMU ?\"\n",
    "# LLMChain(prompt=prompt, llm=llm).run(question)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "56e02d46-c7b9-4688-8134-e59037b775c7",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "iamu2",
   "language": "python",
   "name": "iamu2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}