为 Argilla 添加新语言¶
如果您想为 Argilla 添加新语言,您需要前往两个地方
- 在文件夹中添加新的翻译规范:
argilla-frontend/translation
。例如,对于代码为ko
的韩语,通过复制en.js
文件来添加ko.js
文件。文本值需要翻译。 - 然后更新 i18n Nuxt:
argilla-frontend/nuxt.config.ts
如何测试¶
- 启动 Argilla 的本地实例,最简单的方法是使用 docker 配方 这里。它将为您提供前端的后端 API。
- 编译新版本的前端。查看 本指南。这基本上是:
git clone https://github.com/argilla-io/argilla
cd argilla-frontend
- 安装依赖项:
npm i
- 使用更新构建新前端:
npm run build
- 通过
npm run start
启动 UI。默认情况下,您可以通过 localhost:3000 访问它。 - 检查翻译。
- 部署一个小型测试数据集,以测试数据集上的翻译。
import argilla as rg client_local = rg.Argilla(api_url="http://localhost:6900/", api_key="argilla.apikey") sample_questions = [ rg.SpanQuestion( name="question1", field="text", labels={ "PERSON": "Person", "ORG": "Organization", "LOC": "Location", "MISC": "Miscellaneous" }, # or ["PERSON", "ORG", "LOC", "MISC"] title="Select the entities in the text", description="Select the entities in the text", required=True, allow_overlapping=False, ), rg.LabelQuestion( name="question2", labels={"YES": "Yes", "NO": "No"}, # or ["YES", "NO"] title="Is the answer relevant to the given prompt?", description="Choose the option that applies.", required=True, ), rg.MultiLabelQuestion( name="question3", labels={ "hate": "Hate speech", "sexual": "Sexual content", "violent": "Violent content", "pii": "Personal information", "untruthful": "False information", "not_english": "Not English", "inappropriate": "Inappropriate content" }, # or ["hate", "sexual", "violent", "pii", "untruthful", "not_english", "inappropriate"] title="Does the response contain any of the following?", description="Select all applicable options.", required=True, visible_labels=3, labels_order="natural" ), rg.RankingQuestion( name="question4", values={ "reply-1": "Answer 1", "reply-2": "Answer 2", "reply-3": "Answer 3" }, # or ["reply-1", "reply-2", "reply-3"] title="Rank the answers by your preference", description="1 = best, 3 = worst. Equal ratings are allowed.", required=True, ), rg.RatingQuestion( name="question5", values=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], title="How satisfied are you with the answer?", description="1 = very dissatisfied, 10 = very satisfied", required=True, ), rg.TextQuestion( name="question6", title="Please provide your feedback on the answer", description="Please provide your feedback on the answer", required=True, use_markdown=True ) ] sample_fields = [ rg.ChatField( name="chat", title="Previous conversation with the customer", use_markdown=True, required=True, description="Dialog between AI & customer up to the last question", ), rg.TextField( name="text", title="Customer's question", use_markdown=False, required=True, description="This is a question from the customer", ), rg.ImageField( name="image", title="Image related to the question", required=True, description="Image sent by the customer", ), ] # Create a new dataset with the same settings as the original settings = rg.Settings( fields=sample_fields, questions=sample_questions, ) new_dataset = rg.Dataset( name="demo_dataset", workspace="default", settings=settings, client=client_local, ) new_dataset.create() def fix_record(): return rg.Record( fields={ "chat": [ {"role": "user", "content": "What is Argilla?"}, {"role": "assistant", "content": "Argilla is a collaboration tool for AI engineers and domain experts to build high-quality datasets"}, ], "image": "https://images.unsplash.com/photo-1523567353-71ea31cb9f73?w=900&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTJ8fGNvcmdpfGVufDB8fDB8fHww", "text": "Which town has a greater population as of the 2010 census, Minden, Nevada or Gardnerville, Nevada?", }, ) new_records = [fix_record() for _ in range(10)] new_dataset.records.log(new_records)
- 测试您的翻译是否也适用于数据集和数据集设置。