Coder Social home page Coder Social logo

cookbook's Introduction

Open-Source AI Cookbook

This repo contains community-driven practical examples of building AI applications and solving various tasks with AI using open-source tools and models.

Contributing to the cookbook

Everyone is welcome to contribute, and we value everybody's contribution! There are several ways you can contribute to the Open-Source AI Cookbook:

  • Submit an idea for a desired example/guide via GitHub Issues.
  • Contribute a new notebook with a practical example.
  • Improve existing examples by fixing issues/typos.

Before contributing, check currently open issues and pull requests to avoid working on something that someone else is already working on.

What makes a good Cookbook notebook?

We believe that the Cookbook will be the most beneficial for everyone in the community if the Jupyter notebooks have the following qualities:

  • Practical: Your notebook should provide an illustration of an end-to-end project or a specific aspect of AI development. Aim for real-world applications, but try to avoid overcomplicating. Clearly explain the objectives, challenges and steps involved.
  • Build with open-source tools and models: Utilize open source libraries, datasets, and pre-trained models available under permissive licenses. Include links to all resources used within the notebook.
  • Clearly written: Ensure your writing is clear, concise, and free from grammatical errors. Maintain a friendly and approachable tone throughout the notebook. Explain the steps you take to solve a problem, challenges, alternative approaches.
  • Executes without errors: Test your notebook to avoid runtime errors.
  • Adds to existing "recipes": Before submitting, review existing notebooks to confirm that the subject hasn't been covered yet. We welcome diverse use cases, modalities, techniques, and approaches!

Creating a pull request

To contribute a new example/guide, open a pull request, and tag @merveenoyan and @stevhliu.

Here are some tips:

  • Make sure that your notebook's file name is in lowercase.
  • Don't forget to add your notebook to the _toctree.yml and to index.md.
  • Right after the notebook's first header, add yourself as an author like this: _Authored by: [Aymeric Roucher](https://huggingface.co/m-ric)_. You can link to your Hugging Face profile, or to your GitHub profile.
  • Remove non-informative code cell outputs (e.g. from pip install). Make sure the notebook doesn't contain any empty code cells.
  • If using any images in the markdown, upload them to the huggingface/cookbook-images dataset. Then use the link to the image in your markdown, e.g.: ![RAG diagram](https://huggingface.co/datasets/huggingface/cookbook-images/resolve/main/rag-diagram.png)

Once your pull request is merged, the notebook will show up in the Open-Source AI Cookbook.

Translating the Cookbook into your language

We'd love to have the Cookbook to be available in many more languages! Please follow the steps below if you'd like to help translate the notebooks into your language ๐Ÿ™.

If some of the notebooks have already been translated into your language, add new translated notebooks under notebooks/your_language. Don't forget to add the new translated notebook to notebooks/your_language/_toctree.yml, and to notebooks/your_language/index.md.

If the notebooks have not yet been translated to your language, create a directory under notebooks with your LANG-ID (e.g. see en for English, zh-CN for Chinese). The LANG-ID should be ISO 639-1 (two lower case letters) language code -- see here for reference. Alternatively, {two lowercase letters}-{two uppercase letters} format is also supported, e.g. zh-CN.

Create the notebooks/LANG-ID/_toctree.yml, and notebooks/LANG-ID/index.md, and add the translated notebook.

Finally, add your language code (the exact same LANG-ID) to the build_documentation.yml and build_pr_documentation.yml files in the .github/workflows folder.

cookbook's People

Contributors

abhikvarma avatar akirusprod avatar andrewrreed avatar aravindputrevu avatar aymeric-roucher avatar emre570 avatar innovation64 avatar jacoblee93 avatar jacobmarks avatar jinnovation avatar kghamilton89 avatar logan-markewich avatar merveenoyan avatar mishig25 avatar mkhalusova avatar moritzlaurer avatar peremartra avatar richmondalake avatar rnckp avatar sdiazlor avatar shubhagyta24 avatar stevhliu avatar taehallm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cookbook's Issues

Train

I want to train a neural network to automatically compile a table of contents, tell me how to properly mark up documents so that it identifies paragraphs, chapters, page numbers, etc.
photo_2024-03-11_10-32-47

Discord channel for Cookbook discussions

@MKhalusova - let me begin by saying thank you. this is an un-issue.

Is there discord channel or huggingface forum set up for discussions related to the cookbook? I've noticed on GitHub recently that there are a few repos that have enabled the discussions feature as well. The LLaVA repo is where I learned about this feature.

The rag_zephyr_langchain.ipynb notebook is great. reinforced and introduced some new concepts.

  • faiss-gpu: I had used this python module before on my Windows 11 system and wasn't expecting issues installing it. Simple reason is that I had used it previously from WSL Ubuntu. May be worth mentioning it.

  • rag-chain: you may want to mention the essential value provided by LangChain's RunnablePassthrough() method.

    • I'm familiar with LangChain but missed this chapter in my learning process. I don't grok it fully yet but my spidey-sense is telling me it was created to get around challenges related to trying to use f-strings in prompts (it's nasty).

    Thanks again!

Translate to Simplified Chinese (zh-CN)

Hi ! I'm doing some RAG research, and I just found your guys' post on this cookbook tutorial. it was awesome. I want to translate it into Chinese. I'm not sure it is ok.

Contribution to Hugging Face ๐Ÿค— cookbook: Add a LangChain agent that can interact with a graph database

You can use more than just vector databases to feed additional context to LLMs. However, the naive approach of generating database queries is too brittle at the moment. Therefore, it is advisable to implement an agent and give it tools to interact with a graph database. The tools use predefined flows and allow agent to solve specific problems. I have a version with OpenAI here: https://towardsdatascience.com/enhancing-interaction-between-language-models-and-graph-databases-via-a-semantic-layer-0a78ad3eba49 Would probably need to use Mixtral 8x7b as an agent.

Quantization Stable Diffusion

I am interested in sharing a notebook about Quantization Stable Diffusion models. It speeds up the performance with lower bit-width and improves efficiency.

PII detection for secure use of LLM api's

I'd love to contribute a PII detection notebook with applications in Finance. Since finance is highly regulated, one of the principal concerns with using any ML endpoints including LLMs is proprietary data being leaked. Some orgs (mine included) use a gateway that filters out PII before hitting the desired endpoint. Wealthsimple has shared a repo on this (https://github.com/wealthsimple/llm-gateway) and if I may contribute, I'll likely make use of their scripts as a starting point and create a walk through covering what using the gateway might look like in an industry setting.

I know that this may not be 100% in the domain of "open-source AI" but given that the biggest barrier most companies face with adopting LLM APIs (at this point, the easiest way for orgs to adopt AI) is the concerns around data privacy, this may encourage adoption faster which can then be a stepping stone towards further ML adoption within the org.

@merveenoyan @stevhliu thoughts?

RAG: Question Answering using Gemma, Elasticsearch & langchain

This is Ashish from Elastic. I'm interested in sharing a notebook that showcases RAG implementation using Elasticsearch. The notebook will illustrate how we generate vectors using Elastic's ELSER model and retrieve semantic results. We'll be utilizing Gemma for contextual question answering.

Contribution to Hugging Face ๐Ÿค— cookbook: Utilize advanced retrieval techniques with Hugging Face LLMs for RAG

I would like to contribute to the Hugging Face ๐Ÿค— repository by adding a notebook on utilizing different retrieval techniques like BM25 retriever, multi-vector retriever, multi-query retriever, ensemble retriever, and merger retriever on document question answering with Hugging Face ๐Ÿค— models as the llms and embedding models.

I've extensively explored langchain's features and would love to contribute to the open source community and share my knowledge.

ValidationError: 1 validation error for agenerate

Hello, @merveenoyan. While my issue isn't directly related to the cookbook, I've encountered an error while using your reference guide for building an instruct dataset using PDFs. I've raised this concern on the agrilla/distilabel repository but haven't received a proper answer yet.

I've attached my notebook along with your cookbook example.
Reference Cookbook Example: https://huggingface.co/learn/cookbook/pipeline_notus_instructions_preferences_legal
Notebook link: https://github.com/KaifAhmad1/code-test/blob/main/Dataset_Creation_using_Distilabel.ipynb

Issue link that I have raised on distilable: argilla-io/distilabel#612

class QuestionAnsweringTask(TextGeneration):
    def generate_prompt(self, question: str) -> str:
        prompt = Prompt(system_prompt=self.system_prompt, formatted_prompt=question)
        formatted_prompt = prompt.format_as("llama2")
        return formatted_prompt

    def parse_output(self, output: str) -> Dict[str, str]:
        return {"answer": output.strip()}

    @property
    def input_args_names(self) -> list[str]:
        return ["question"]

    @property
    def output_args_names(self) -> list[str]:
        return ["answer"]

from distilabel.llms.huggingface import InferenceEndpointsLLM

# Free serverless Inference API
llm = InferenceEndpointsLLM(
    model_id="mistralai/Mistral-7B-Instruct-v0.2",
    api_key="My HF Token"
)
llm.load()

# input 
inputs = [{"question": "What's the second most populated city in Denmark?"}]
generation = llm.generate(inputs)
print(generation[0][0]["parsed_output"]["answer"])
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ in <cell line: 3>:3                                                                              โ”‚
โ”‚ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ locals โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚
โ”‚ โ”‚                        Dataset = <class 'datasets.arrow_dataset.Dataset'>                    โ”‚ โ”‚
โ”‚ โ”‚                           Dict = typing.Dict                                                 โ”‚ โ”‚
โ”‚ โ”‚                       document = [                                                           โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN   EN \n \n \n EUROPEAN             โ”‚ โ”‚
โ”‚ โ”‚                                  \nCOMMISSION   \nBrussels, 21.4.2021  \nCOM(2021) 206       โ”‚ โ”‚
โ”‚ โ”‚                                  final'+308,                                                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 0                                       โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN 1  EN EXPLANATORY MEMORANDUM  \n1. โ”‚ โ”‚
โ”‚ โ”‚                                  CONTEXT  OF THE  PROPOSAL  \n1.1. Reasons fo'+3873,         โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 1                                       โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN 2  EN intelligence as stated by    โ”‚ โ”‚
โ”‚ โ”‚                                  the European Council3 and ensures the protect'+4148,        โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 2                                       โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN 3  EN proposal takes into account  โ”‚ โ”‚
โ”‚ โ”‚                                  the aforementioned resolution of the Europe'+3626,          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 3                                       โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN 4  EN 1.2. Consistency with        โ”‚ โ”‚
โ”‚ โ”‚                                  existing policy pr ovisions in the policy area  \n'+3902,   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 4                                       โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN 5  EN This proposal is also        โ”‚ โ”‚
โ”‚ โ”‚                                  consistent with the applicable Union legislation '+3839,    โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 5                                       โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN 6  EN 2. LEGAL  BASIS,             โ”‚ โ”‚
โ”‚ โ”‚                                  SUBSIDIARITY  AND  PROPORTIONALITY  \n2.1. Legal            โ”‚ โ”‚
โ”‚ โ”‚                                  basi'+3628,                                                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 6                                       โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN 7  EN 2.3. Proportionality  \nThe  โ”‚ โ”‚
โ”‚ โ”‚                                  proposal builds on existing legal frameworks'+3464,         โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 7                                       โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN 8  EN academic/research            โ”‚ โ”‚
โ”‚ โ”‚                                  institutions, a nd 73 from public authorities. Civil        โ”‚ โ”‚
โ”‚ โ”‚                                  '+3721,                                                     โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 8                                       โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN 9  EN In addition, the AI          โ”‚ โ”‚
โ”‚ โ”‚                                  Alliance26 was formed as a platform for approximate'+3401,  โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 9                                       โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ... +98                                                 โ”‚ โ”‚
โ”‚ โ”‚                                  ]                                                           โ”‚ โ”‚
โ”‚ โ”‚                          drive = <module 'google.colab.drive' from                           โ”‚ โ”‚
โ”‚ โ”‚                                  '/usr/local/lib/python3.10/dist-packages/google/colab/drivโ€ฆ โ”‚ โ”‚
โ”‚ โ”‚                           exit = <IPython.core.autocall.ZMQExitAutocall object at            โ”‚ โ”‚
โ”‚ โ”‚                                  0x7db0dbc37d90>                                             โ”‚ โ”‚
โ”‚ โ”‚                    get_ipython = <bound method InteractiveShell.get_ipython of               โ”‚ โ”‚
โ”‚ โ”‚                                  <google.colab._shell.Shell object at 0x7db0dbc377f0>>       โ”‚ โ”‚
โ”‚ โ”‚                             In = [                                                           โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   '',                                                     โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   "get_ipython().system('pip install -qU distilabel       โ”‚ โ”‚
โ”‚ โ”‚                                  langchain pypdf')",                                         โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   'import os\nfrom typing import Dict\nfrom               โ”‚ โ”‚
โ”‚ โ”‚                                  distilabel.llms.huggingface import Infere'+120,             โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   'os.environ["HF_TOKEN"] =                               โ”‚ โ”‚
โ”‚ โ”‚                                  "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"\nos.environ["HF_'+โ€ฆ โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   'from datasets import Dataset\nfrom                     โ”‚ โ”‚
โ”‚ โ”‚                                  langchain_community.document_loaders import Py'+9,          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   "from google.colab import                               โ”‚ โ”‚
โ”‚ โ”‚                                  drive\ndrive.mount('/content/drive')",                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   'loader =                                               โ”‚ โ”‚
โ”‚ โ”‚                                  PyPDFLoader("/content/drive/MyDrive/EU_AI_Act_Doc.pdf")\ndโ€ฆ โ”‚ โ”‚
โ”‚ โ”‚                                  = load'+9,                                                  โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   'print(len(document))',                                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   'from langchain.text_splitter import                    โ”‚ โ”‚
โ”‚ โ”‚                                  RecursiveCharacterTextSplitter\nMARKDOWN_SEPA'+318,         โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   'splits = text_splitter.split_documents(document)',     โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ... +46                                                 โ”‚ โ”‚
โ”‚ โ”‚                                  ]                                                           โ”‚ โ”‚
โ”‚ โ”‚          InferenceEndpointsLLM = <class                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  'distilabel.llms.huggingface.inference_endpoints.Inferenceโ€ฆ โ”‚ โ”‚
โ”‚ โ”‚                         inputs = [                                                           โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   {                                                       โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   'question': "What's the second most populated city  โ”‚ โ”‚
โ”‚ โ”‚                                  in Denmark?"                                                โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   }                                                       โ”‚ โ”‚
โ”‚ โ”‚                                  ]                                                           โ”‚ โ”‚
โ”‚ โ”‚           instructions_dataset = Dataset({                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   features: ['input'],                                    โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   num_rows: 50                                            โ”‚ โ”‚
โ”‚ โ”‚                                  })                                                          โ”‚ โ”‚
โ”‚ โ”‚                            llm = InferenceEndpointsLLM(                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   generation_kwargs={},                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   model_id='mistralai/Mistral-7B-Instruct-v0.2',          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   endpoint_name=None,                                     โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   endpoint_namespace=None,                                โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚                                                           โ”‚ โ”‚
โ”‚ โ”‚                                  base_url='https://api-inference.huggingface.co/models/mistโ€ฆ โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   api_key=SecretStr('**********'),                        โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   tokenizer_id=None,                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   model_display_name=None,                                โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   use_openai_client=False                                 โ”‚ โ”‚
โ”‚ โ”‚                                  )                                                           โ”‚ โ”‚
โ”‚ โ”‚                         loader = <langchain_community.document_loaders.pdf.PyPDFLoader       โ”‚ โ”‚
โ”‚ โ”‚                                  object at 0x7db095942c50>                                   โ”‚ โ”‚
โ”‚ โ”‚            MARKDOWN_SEPARATORS = [                                                           โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   '\n#{1,6} ',                                            โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   '```\n',                                                โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   '\n\\*\\*\\*+\n',                                       โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   '\n---+\n',                                             โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   '\n___+\n',                                             โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   '\n\n',                                                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   '\n',                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ' ',                                                    โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ''                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  ]                                                           โ”‚ โ”‚
โ”‚ โ”‚                             os = <module 'os' from '/usr/lib/python3.10/os.py'>              โ”‚ โ”‚
โ”‚ โ”‚                            Out = {                                                           โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   10: 'EN 6  EN 2. LEGAL  BASIS,  SUBSIDIARITY  AND       โ”‚ โ”‚
โ”‚ โ”‚                                  PROPORTIONALITY  \n2.1. Legal  basi'+901,                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   11: 'EN   EN \n \n \n EUROPEAN  \nCOMMISSION            โ”‚ โ”‚
โ”‚ โ”‚                                  \nBrussels, 21.4.2021  \nCOM(2021) 206 final'+308,          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   12: Dataset({                                           โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   features: ['input'],                                    โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   num_rows: 50                                            โ”‚ โ”‚
โ”‚ โ”‚                                  }),                                                         โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   31: 'EN 6  EN 2. LEGAL  BASIS,  SUBSIDIARITY  AND       โ”‚ โ”‚
โ”‚ โ”‚                                  PROPORTIONALITY  \n2.1. Legal  basi'+901,                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   32: 'EN   EN \n \n \n EUROPEAN  \nCOMMISSION            โ”‚ โ”‚
โ”‚ โ”‚                                  \nBrussels, 21.4.2021  \nCOM(2021) 206 final'+308,          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   33: Dataset({                                           โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   features: ['input'],                                    โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   num_rows: 50                                            โ”‚ โ”‚
โ”‚ โ”‚                                  }),                                                         โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   47: 'EN 6  EN 2. LEGAL  BASIS,  SUBSIDIARITY  AND       โ”‚ โ”‚
โ”‚ โ”‚                                  PROPORTIONALITY  \n2.1. Legal  basi'+901,                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   48: 'EN   EN \n \n \n EUROPEAN  \nCOMMISSION            โ”‚ โ”‚
โ”‚ โ”‚                                  \nBrussels, 21.4.2021  \nCOM(2021) 206 final'+308,          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   49: Dataset({                                           โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   features: ['input'],                                    โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   num_rows: 50                                            โ”‚ โ”‚
โ”‚ โ”‚                                  })                                                          โ”‚ โ”‚
โ”‚ โ”‚                                  }                                                           โ”‚ โ”‚
โ”‚ โ”‚                       Pipeline = <class 'distilabel.pipeline.local.Pipeline'>                โ”‚ โ”‚
โ”‚ โ”‚                    PyPDFLoader = <class                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  'langchain_community.document_loaders.pdf.PyPDFLoader'>     โ”‚ โ”‚
โ”‚ โ”‚          QuestionAnsweringTask = <class '__main__.QuestionAnsweringTask'>                    โ”‚ โ”‚
โ”‚ โ”‚                           quit = <IPython.core.autocall.ZMQExitAutocall object at            โ”‚ โ”‚
โ”‚ โ”‚                                  0x7db0dbc37d90>                                             โ”‚ โ”‚
โ”‚ โ”‚ RecursiveCharacterTextSplitter = <class                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  'langchain_text_splitters.character.RecursiveCharacterTextโ€ฆ โ”‚ โ”‚
โ”‚ โ”‚                   SelfInstruct = <class 'distilabel.steps.tasks.self_instruct.SelfInstruct'> โ”‚ โ”‚
โ”‚ โ”‚                         splits = [                                                           โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN   EN \n \n \n EUROPEAN             โ”‚ โ”‚
โ”‚ โ”‚                                  \nCOMMISSION   \nBrussels, 21.4.2021  \nCOM(2021) 206       โ”‚ โ”‚
โ”‚ โ”‚                                  final'+305,                                                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 0,                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'start_index': 0                                โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN 1  EN EXPLANATORY MEMORANDUM  \n1. โ”‚ โ”‚
โ”‚ โ”‚                                  CONTEXT  OF THE  PROPOSAL  \n1.1. Reasons fo'+875,          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 1,                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'start_index': 0                                โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='elements and techniques that power    โ”‚ โ”‚
โ”‚ โ”‚                                  the socio -economic benefits of AI can also b'+877,         โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 1,                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'start_index': 957                              โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='to excellence and trust2. The White   โ”‚ โ”‚
โ”‚ โ”‚                                  Paper sets out policy options on how  to ach'+848,          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 1,                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'start_index': 1916                             โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='of fundamental rights. Following the  โ”‚ โ”‚
โ”‚ โ”‚                                  publication of the White Paper, the Commiss'+887,           โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 1,                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'start_index': 2846                             โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='2 European Commission, White Paper on โ”‚ โ”‚
โ”‚ โ”‚                                  Artificial Intelligence - A European appro'+55,             โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 1,                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'start_index': 3816                             โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='EN 2  EN intelligence as stated by    โ”‚ โ”‚
โ”‚ โ”‚                                  the European Council3 and ensures the protect'+836,         โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 2,                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'start_index': 0                                โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='The most recent Conclusi ons from 21  โ”‚ โ”‚
โ”‚ โ”‚                                  October 2020  further called for addressing'+876,           โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 2,                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'start_index': 919                              โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='resolution includes a text of the     โ”‚ โ”‚
โ”‚ โ”‚                                  legislative proposal for a regulation on ethic'+880,        โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 2,                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'start_index': 1877                             โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   Document(                                               โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   page_content='artificial intelligence -Adoption     โ”‚ โ”‚
โ”‚ โ”‚                                  6177/19, 2019.  \n7 European Council, Special '+894,        โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   metadata={                                          โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'source':                                       โ”‚ โ”‚
โ”‚ โ”‚                                  '/content/drive/MyDrive/EU_AI_Act_Doc.pdf',                 โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'page': 2,                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   โ”‚   'start_index': 2839                             โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   โ”‚   }                                                   โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ),                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  โ”‚   ... +372                                                โ”‚ โ”‚
โ”‚ โ”‚                                  ]                                                           โ”‚ โ”‚
โ”‚ โ”‚                  text_splitter = <langchain_text_splitters.character.RecursiveCharacterTextโ€ฆ โ”‚ โ”‚
โ”‚ โ”‚                                  object at 0x7db097424ee0>                                   โ”‚ โ”‚
โ”‚ โ”‚                 TextGeneration = <class                                                      โ”‚ โ”‚
โ”‚ โ”‚                                  'distilabel.steps.tasks.text_generation.TextGeneration'>    โ”‚ โ”‚
โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ /usr/local/lib/python3.10/dist-packages/distilabel/llms/huggingface/inference_endpoints.py:407   โ”‚
โ”‚ in generate                                                                                      โ”‚
โ”‚                                                                                                  โ”‚
โ”‚   404 โ”‚   โ”‚   โ”‚   ]                                                                              โ”‚
โ”‚   405 โ”‚   โ”‚   โ”‚   return [outputs[0] for outputs in await asyncio.gather(*tasks)]                โ”‚
โ”‚   406 โ”‚   โ”‚                                                                                      โ”‚
โ”‚ โฑ 407 โ”‚   โ”‚   outputs = self.event_loop.run_until_complete(agenerate(inputs, **kwargs))          โ”‚
โ”‚   408 โ”‚   โ”‚   return list(grouper(outputs, n=num_generations, incomplete="ignore"))              โ”‚
โ”‚   409                                                                                            โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ locals โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚
โ”‚ โ”‚       agenerate = <function InferenceEndpointsLLM.generate.<locals>.agenerate at             โ”‚ โ”‚
โ”‚ โ”‚                   0x7db0973eb1c0>                                                            โ”‚ โ”‚
โ”‚ โ”‚          inputs = [{'question': "What's the second most populated city in Denmark?"}]        โ”‚ โ”‚
โ”‚ โ”‚          kwargs = {}                                                                         โ”‚ โ”‚
โ”‚ โ”‚ num_generations = 1                                                                          โ”‚ โ”‚
โ”‚ โ”‚            self = InferenceEndpointsLLM(                                                     โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   generation_kwargs={},                                                  โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   model_id='mistralai/Mistral-7B-Instruct-v0.2',                         โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   endpoint_name=None,                                                    โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   endpoint_namespace=None,                                               โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚                                                                          โ”‚ โ”‚
โ”‚ โ”‚                   base_url='https://api-inference.huggingface.co/models/mistralai/Mistral-7โ€ฆ โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   api_key=SecretStr('**********'),                                       โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   tokenizer_id=None,                                                     โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   model_display_name=None,                                               โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   use_openai_client=False                                                โ”‚ โ”‚
โ”‚ โ”‚                   )                                                                          โ”‚ โ”‚
โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ /usr/local/lib/python3.10/dist-packages/nest_asyncio.py:98 in run_until_complete                 โ”‚
โ”‚                                                                                                  โ”‚
โ”‚    95 โ”‚   โ”‚   โ”‚   if not f.done():                                                               โ”‚
โ”‚    96 โ”‚   โ”‚   โ”‚   โ”‚   raise RuntimeError(                                                        โ”‚
โ”‚    97 โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   'Event loop stopped before Future completed.')                         โ”‚
โ”‚ โฑ  98 โ”‚   โ”‚   โ”‚   return f.result()                                                              โ”‚
โ”‚    99 โ”‚                                                                                          โ”‚
โ”‚   100 โ”‚   def _run_once(self):                                                                   โ”‚
โ”‚   101 โ”‚   โ”‚   """                                                                                โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ locals โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚
โ”‚ โ”‚          f = <Task finished name='Task-8'                                                    โ”‚ โ”‚
โ”‚ โ”‚              coro=<InferenceEndpointsLLM.generate.<locals>.agenerate() done, defined at      โ”‚ โ”‚
โ”‚ โ”‚              /usr/local/lib/python3.10/dist-packages/distilabel/llms/huggingface/inference_โ€ฆ โ”‚ โ”‚
โ”‚ โ”‚              exception=1 validation error for agenerate                                      โ”‚ โ”‚
โ”‚ โ”‚              input                                                                           โ”‚ โ”‚
โ”‚ โ”‚                Input should be a valid list [type=list_type, input_value={'question':        โ”‚ โ”‚
โ”‚ โ”‚              "What's the ...lated city in Denmark?"}, input_type=dict]                       โ”‚ โ”‚
โ”‚ โ”‚              โ”‚   For further information visit https://errors.pydantic.dev/2.7/v/list_type>  โ”‚ โ”‚
โ”‚ โ”‚     future = <coroutine object InferenceEndpointsLLM.generate.<locals>.agenerate at          โ”‚ โ”‚
โ”‚ โ”‚              0x7db0979c57e0>                                                                 โ”‚ โ”‚
โ”‚ โ”‚ manage_run = <function _patch_loop.<locals>.manage_run at 0x7db0ad7fb010>                    โ”‚ โ”‚
โ”‚ โ”‚       self = <_UnixSelectorEventLoop running=True closed=False debug=False>                  โ”‚ โ”‚
โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ /usr/lib/python3.10/asyncio/futures.py:201 in result                                             โ”‚
โ”‚                                                                                                  โ”‚
โ”‚   198 โ”‚   โ”‚   โ”‚   raise exceptions.InvalidStateError('Result is not ready.')                     โ”‚
โ”‚   199 โ”‚   โ”‚   self.__log_traceback = False                                                       โ”‚
โ”‚   200 โ”‚   โ”‚   if self._exception is not None:                                                    โ”‚
โ”‚ โฑ 201 โ”‚   โ”‚   โ”‚   raise self._exception.with_traceback(self._exception_tb)                       โ”‚
โ”‚   202 โ”‚   โ”‚   return self._result                                                                โ”‚
โ”‚   203 โ”‚                                                                                          โ”‚
โ”‚   204 โ”‚   def exception(self):                                                                   โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ locals โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚
โ”‚ โ”‚ self = <Task finished name='Task-8'                                                          โ”‚ โ”‚
โ”‚ โ”‚        coro=<InferenceEndpointsLLM.generate.<locals>.agenerate() done, defined at            โ”‚ โ”‚
โ”‚ โ”‚        /usr/local/lib/python3.10/dist-packages/distilabel/llms/huggingface/inference_endpoiโ€ฆ โ”‚ โ”‚
โ”‚ โ”‚        exception=1 validation error for agenerate                                            โ”‚ โ”‚
โ”‚ โ”‚        input                                                                                 โ”‚ โ”‚
โ”‚ โ”‚          Input should be a valid list [type=list_type, input_value={'question': "What's the  โ”‚ โ”‚
โ”‚ โ”‚        ...lated city in Denmark?"}, input_type=dict]                                         โ”‚ โ”‚
โ”‚ โ”‚        โ”‚   For further information visit https://errors.pydantic.dev/2.7/v/list_type>        โ”‚ โ”‚
โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ /usr/lib/python3.10/asyncio/tasks.py:232 in __step                                               โ”‚
โ”‚                                                                                                  โ”‚
โ”‚   229 โ”‚   โ”‚   โ”‚   if exc is None:                                                                โ”‚
โ”‚   230 โ”‚   โ”‚   โ”‚   โ”‚   # We use the `send` method directly, because coroutines                    โ”‚
โ”‚   231 โ”‚   โ”‚   โ”‚   โ”‚   # don't have `__iter__` and `__next__` methods.                            โ”‚
โ”‚ โฑ 232 โ”‚   โ”‚   โ”‚   โ”‚   result = coro.send(None)                                                   โ”‚
โ”‚   233 โ”‚   โ”‚   โ”‚   else:                                                                          โ”‚
โ”‚   234 โ”‚   โ”‚   โ”‚   โ”‚   result = coro.throw(exc)                                                   โ”‚
โ”‚   235 โ”‚   โ”‚   except StopIteration as exc:                                                       โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ locals โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚
โ”‚ โ”‚ coro = <coroutine object InferenceEndpointsLLM.generate.<locals>.agenerate at                โ”‚ โ”‚
โ”‚ โ”‚        0x7db0979c57e0>                                                                       โ”‚ โ”‚
โ”‚ โ”‚ self = None                                                                                  โ”‚ โ”‚
โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ /usr/local/lib/python3.10/dist-packages/distilabel/llms/huggingface/inference_endpoints.py:400   โ”‚
โ”‚ in agenerate                                                                                     โ”‚
โ”‚                                                                                                  โ”‚
โ”‚   397 โ”‚   โ”‚   โ”‚   inputs: List["ChatType"], **kwargs: Any                                        โ”‚
โ”‚   398 โ”‚   โ”‚   ) -> "GenerateOutput":                                                             โ”‚
โ”‚   399 โ”‚   โ”‚   โ”‚   """Internal function to parallelize the asynchronous generation of responses   โ”‚
โ”‚ โฑ 400 โ”‚   โ”‚   โ”‚   tasks = [                                                                      โ”‚
โ”‚   401 โ”‚   โ”‚   โ”‚   โ”‚   asyncio.create_task(self.agenerate(input=input, **kwargs))                 โ”‚
โ”‚   402 โ”‚   โ”‚   โ”‚   โ”‚   for input in inputs                                                        โ”‚
โ”‚   403 โ”‚   โ”‚   โ”‚   โ”‚   for _ in range(num_generations)                                            โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ locals โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚
โ”‚ โ”‚          inputs = [{'question': "What's the second most populated city in Denmark?"}]        โ”‚ โ”‚
โ”‚ โ”‚          kwargs = {}                                                                         โ”‚ โ”‚
โ”‚ โ”‚ num_generations = 1                                                                          โ”‚ โ”‚
โ”‚ โ”‚            self = InferenceEndpointsLLM(                                                     โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   generation_kwargs={},                                                  โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   model_id='mistralai/Mistral-7B-Instruct-v0.2',                         โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   endpoint_name=None,                                                    โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   endpoint_namespace=None,                                               โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚                                                                          โ”‚ โ”‚
โ”‚ โ”‚                   base_url='https://api-inference.huggingface.co/models/mistralai/Mistral-7โ€ฆ โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   api_key=SecretStr('**********'),                                       โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   tokenizer_id=None,                                                     โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   model_display_name=None,                                               โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   use_openai_client=False                                                โ”‚ โ”‚
โ”‚ โ”‚                   )                                                                          โ”‚ โ”‚
โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ /usr/local/lib/python3.10/dist-packages/distilabel/llms/huggingface/inference_endpoints.py:401   โ”‚
โ”‚ in <listcomp>                                                                                    โ”‚
โ”‚                                                                                                  โ”‚
โ”‚   398 โ”‚   โ”‚   ) -> "GenerateOutput":                                                             โ”‚
โ”‚   399 โ”‚   โ”‚   โ”‚   """Internal function to parallelize the asynchronous generation of responses   โ”‚
โ”‚   400 โ”‚   โ”‚   โ”‚   tasks = [                                                                      โ”‚
โ”‚ โฑ 401 โ”‚   โ”‚   โ”‚   โ”‚   asyncio.create_task(self.agenerate(input=input, **kwargs))                 โ”‚
โ”‚   402 โ”‚   โ”‚   โ”‚   โ”‚   for input in inputs                                                        โ”‚
โ”‚   403 โ”‚   โ”‚   โ”‚   โ”‚   for _ in range(num_generations)                                            โ”‚
โ”‚   404 โ”‚   โ”‚   โ”‚   ]                                                                              โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ locals โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚
โ”‚ โ”‚              .0 = <list_iterator object at 0x7db0957fd210>                                   โ”‚ โ”‚
โ”‚ โ”‚           input = {'question': "What's the second most populated city in Denmark?"}          โ”‚ โ”‚
โ”‚ โ”‚          kwargs = {}                                                                         โ”‚ โ”‚
โ”‚ โ”‚ num_generations = 1                                                                          โ”‚ โ”‚
โ”‚ โ”‚            self = InferenceEndpointsLLM(                                                     โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   generation_kwargs={},                                                  โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   model_id='mistralai/Mistral-7B-Instruct-v0.2',                         โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   endpoint_name=None,                                                    โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   endpoint_namespace=None,                                               โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚                                                                          โ”‚ โ”‚
โ”‚ โ”‚                   base_url='https://api-inference.huggingface.co/models/mistralai/Mistral-7โ€ฆ โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   api_key=SecretStr('**********'),                                       โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   tokenizer_id=None,                                                     โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   model_display_name=None,                                               โ”‚ โ”‚
โ”‚ โ”‚                   โ”‚   use_openai_client=False                                                โ”‚ โ”‚
โ”‚ โ”‚                   )                                                                          โ”‚ โ”‚
โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ /usr/local/lib/python3.10/dist-packages/pydantic/validate_call_decorator.py:59 in                โ”‚
โ”‚ wrapper_function                                                                                 โ”‚
โ”‚                                                                                                  โ”‚
โ”‚   56 โ”‚   โ”‚                                                                                       โ”‚
โ”‚   57 โ”‚   โ”‚   @functools.wraps(function)                                                          โ”‚
โ”‚   58 โ”‚   โ”‚   def wrapper_function(*args, **kwargs):                                              โ”‚
โ”‚ โฑ 59 โ”‚   โ”‚   โ”‚   return validate_call_wrapper(*args, **kwargs)                                   โ”‚
โ”‚   60 โ”‚   โ”‚                                                                                       โ”‚
โ”‚   61 โ”‚   โ”‚   wrapper_function.raw_function = function  # type: ignore                            โ”‚
โ”‚   62                                                                                             โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ locals โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚
โ”‚ โ”‚                  args = (                                                                    โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   InferenceEndpointsLLM(                                           โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   โ”‚   generation_kwargs={},                                        โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   โ”‚   model_id='mistralai/Mistral-7B-Instruct-v0.2',               โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   โ”‚   endpoint_name=None,                                          โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   โ”‚   endpoint_namespace=None,                                     โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   โ”‚                                                                โ”‚ โ”‚
โ”‚ โ”‚                         base_url='https://api-inference.huggingface.co/models/mistralai/Misโ€ฆ โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   โ”‚   api_key=SecretStr('**********'),                             โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   โ”‚   tokenizer_id=None,                                           โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   โ”‚   model_display_name=None,                                     โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   โ”‚   use_openai_client=False                                      โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   ),                                                               โ”‚ โ”‚
โ”‚ โ”‚                         )                                                                    โ”‚ โ”‚
โ”‚ โ”‚                kwargs = {                                                                    โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   'input': {                                                       โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   โ”‚   'question': "What's the second most populated city in        โ”‚ โ”‚
โ”‚ โ”‚                         Denmark?"                                                            โ”‚ โ”‚
โ”‚ โ”‚                         โ”‚   }                                                                โ”‚ โ”‚
โ”‚ โ”‚                         }                                                                    โ”‚ โ”‚
โ”‚ โ”‚ validate_call_wrapper = <pydantic._internal._validate_call.ValidateCallWrapper object at     โ”‚ โ”‚
โ”‚ โ”‚                         0x7db099202a70>                                                      โ”‚ โ”‚
โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ /usr/local/lib/python3.10/dist-packages/pydantic/_internal/_validate_call.py:81 in __call__      โ”‚
โ”‚                                                                                                  โ”‚
โ”‚   78 โ”‚   โ”‚   โ”‚   self.__return_pydantic_validator__ = None                                       โ”‚
โ”‚   79 โ”‚                                                                                           โ”‚
โ”‚   80 โ”‚   def __call__(self, *args: Any, **kwargs: Any) -> Any:                                   โ”‚
โ”‚ โฑ 81 โ”‚   โ”‚   res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args,    โ”‚
โ”‚   82 โ”‚   โ”‚   if self.__return_pydantic_validator__:                                              โ”‚
โ”‚   83 โ”‚   โ”‚   โ”‚   return self.__return_pydantic_validator__(res)                                  โ”‚
โ”‚   84 โ”‚   โ”‚   return res                                                                          โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ locals โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚
โ”‚ โ”‚   args = (                                                                                   โ”‚ โ”‚
โ”‚ โ”‚          โ”‚   InferenceEndpointsLLM(                                                          โ”‚ โ”‚
โ”‚ โ”‚          โ”‚   โ”‚   generation_kwargs={},                                                       โ”‚ โ”‚
โ”‚ โ”‚          โ”‚   โ”‚   model_id='mistralai/Mistral-7B-Instruct-v0.2',                              โ”‚ โ”‚
โ”‚ โ”‚          โ”‚   โ”‚   endpoint_name=None,                                                         โ”‚ โ”‚
โ”‚ โ”‚          โ”‚   โ”‚   endpoint_namespace=None,                                                    โ”‚ โ”‚
โ”‚ โ”‚          โ”‚   โ”‚                                                                               โ”‚ โ”‚
โ”‚ โ”‚          base_url='https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instrucโ€ฆ โ”‚ โ”‚
โ”‚ โ”‚          โ”‚   โ”‚   api_key=SecretStr('**********'),                                            โ”‚ โ”‚
โ”‚ โ”‚          โ”‚   โ”‚   tokenizer_id=None,                                                          โ”‚ โ”‚
โ”‚ โ”‚          โ”‚   โ”‚   model_display_name=None,                                                    โ”‚ โ”‚
โ”‚ โ”‚          โ”‚   โ”‚   use_openai_client=False                                                     โ”‚ โ”‚
โ”‚ โ”‚          โ”‚   ),                                                                              โ”‚ โ”‚
โ”‚ โ”‚          )                                                                                   โ”‚ โ”‚
โ”‚ โ”‚ kwargs = {'input': {'question': "What's the second most populated city in Denmark?"}}        โ”‚ โ”‚
โ”‚ โ”‚   self = <pydantic._internal._validate_call.ValidateCallWrapper object at 0x7db099202a70>    โ”‚ โ”‚
โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
ValidationError: 1 validation error for agenerate
input
  Input should be a valid list [type=list_type, input_value={'question': "What's the ...lated city in Denmark?"}, 
input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/list_type


Step 5 and Step 6 are out of order in **rag_with_hugging_face_gemma_mongodb.ipynb**

In the rag_with_hugging_face_gemma_mongodb.ipynb notebook, Step 5 is to create a vector search index in the movie_collection_2 MongoDB collection, but this collection has not been created yet in the notebook and it is later created in Step 6. Therefore, I think these two steps are out of order and should be switched.

The notebook is also missing the instructions to create an atlas vector search index in Step 5. It says "Follow instructions here:" but then the next paragraph does not contain instructions.

https://github.com/huggingface/cookbook/blob/main/notebooks/en/rag_with_hugging_face_gemma_mongodb.ipynb

Contribution to Hugging Face ๐Ÿค— cookbook: Add two tutorials on Setfit and using HF Inference Endpoints

From Argilla, we would like to contribute with two new tutorials.

  • Fine-tune a SetFit model using the ArgillaTrainer: to learn how to use the ArgillaTrainer to fine-tune a SetFit model on a FeedbackDataset made of categorical questions like LabelQuestion and MultiLabelQuestion.
  • Create a legal preference dataset: to learn how to use the Notus model on Inference Endpoints to create a legal preference dataset based on RAG instructions from the European AI Act

Structured Text-to-SQL generation using Hugging Face and Outlines

Hi y'all, I thought about writing a notebook that showcases how to create a natural language interface for databases using Hugging Face models, Outlines for structured generation and Lark as a parser for syntax checks.

Outlines is a library that constrain auto-regressive text generation models on outputting text that matches regular expressions, JSON schemas or even grammars, which is pretty amazing.

What do you think @MKhalusova ?

Comprehensive Cookbook for Fine-tuning Gemma Model on Mental Health Assistant Dataset

The cookbook aims to provide a comprehensive guide for researchers and practitioners interested in fine-tuning the Gemma model from Google on a mental health assistant dataset.

Key components of the cookbook include an introduction to the Gemma model, a description of the dataset, preprocessing steps, fine-tuning Gemma using the Hugging Face Transformers library, training procedures, and usage examples. The cookbook will also provide guidance on training parameters, etc. This will help expand the available cookbook resources for leveraging Hugging Face models in various domains.

Usage Examples: Illustrative examples demonstrate how to use the fine-tuned Gemma model for various mental health support tasks, such as response generation.

Manually selectively hide or show cell outputs

Since the notebook will be rendered as doc page. For clarity, we need to manually choose which cell outputs to show or hide.

For example, this is a good cell output that should be left visible. This cell output adds context and necessary information

image

from FAISS_with_HF_datasets_and_CLIP.ipynb

On the contrary, we should hide this cell output (warnings, install processes, etc)

image image image

By hide/show, I mean: make a PR to this repo making necessary changes to the notebooks. You can hide the cell outputs in jupyter notebook. And if necessary, you can change python logging to suppress warnings & only output errors

cc: @MKhalusova @aymeric-roucher

Call for Contributions

Hello folks! ๐Ÿ™‹โ€โ™€๏ธ
Wanted to post here the roadmap we have for the cookbook. The cookbook is made for industry/applied AI use cases.
In the upcoming weeks, we would like to have more recipes on the following topics:

  • Industry-specific recipes: domains like biomedical, legal, finance, and so on require know-how in handling data and the model. You can either contribute an end-to-end Hugging Face example with domain-specific data (can be NLP, computer vision, anything) or demonstrate your library.
  • Use cases in other domains: are missing, such as computer vision, multimodal and more. Would be great to have more notebooks.
  • Niche techniques built for production: Such as making model faster for real-time prediction with quantization/optimization, or data privacy preservation techniques like federated learning.

In all of above, you can either do Hugging Face e2e workflows or demonstrate your own library or any library you'd like to use.

Feel free to let us know or open a discussion or issue here if you have ideas and you'd like to validate โ˜บ๏ธ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.