NVIDIA / NeMo-Guardrails

NeMo Guardrails is an open-source toolkit for easily adding programmable guardrails to LLM-based conversational systems.
Other
4.09k stars 380 forks source link

1 validation error for HuggingFaceHub #662

Open qifuxiao opened 2 months ago

qifuxiao commented 2 months ago

I run it in colab,

config.yml:

models:
  - type: main
    engine: huggingface_hub
    model: baichuan-inc/Baichuan2-7B-Chat

rails:
  input:
    flows:
      - self check input

  output:
    flows:
      - self check output

jupyter code:

import os

from google.colab import userdata
os.environ["HUGGINGFACEHUB_API_TOKEN"] = userdata.get('HUGGINGFACEHUB_API_TOKEN')
print(os.environ["HUGGINGFACEHUB_API_TOKEN"])

from nemoguardrails import RailsConfig, LLMRails

config = RailsConfig.from_path("./config")
rails = LLMRails(config)

return Error:

ValidationError                           Traceback (most recent call last)
[<ipython-input-16-285c50de0d73>](https://localhost:8080/#) in <cell line: 4>()
      2 
      3 config = RailsConfig.from_path("./config")
----> 4 rails = LLMRails(config)

3 frames
[/usr/local/lib/python3.10/dist-packages/pydantic/v1/main.py](https://localhost:8080/#) in __init__(__pydantic_self__, **data)
    339         values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
    340         if validation_error:
--> 341             raise validation_error
    342         try:
    343             object_setattr(__pydantic_self__, '__dict__', values)

ValidationError: 1 validation error for HuggingFaceHub
__root__
  Must specify either `repo_id` or `task`, or both. (type=value_error)`

how can I use it in "baichuan-inc/Baichuan2-7B-Chat"

drazvan commented 2 months ago

Just based on the error, I guess you have to do something like:

models:
  - type: main
    engine: huggingface_hub
    model: baichuan-inc/Baichuan2-7B-Chat
    parameters:
      task: "..."
      repo_id: "..."

Let me know if this works.