Commit cf40a31
[HF Data Loader] Load onechat datasets with externally defined mappings. (elastic#230252)
## Summary
Closes: elastic#227993
This PR introduces OneChat datasets to the HuggingFace dataset loader
CLI tool.
### Key Changes
* OneChat Data Loading Support
- Added support for loading OneChat datasets (CSV-based) from
the `elastic/OneChatAgent` repository.
- OneChat datasets can now be specified using
the `onechat/<directory>/<dataset>` syntax.
* Refactored File Download and Parsing
- Extracted HuggingFace file download logic for reuse.
- Separated CSV and JSON parsing into dedicated functions for clarity
and maintainability. Previously only JSON download was supported. This
uses `papaparse` library for csv parsing which was very handy for
parsing multi-line csv files.
* Configurable Kibana URL
- The loader now accepts a `--kibana-url` flag to override
auto-discovery of the Kibana instance. This is needed locally for the
evaluation framework that uses scout server running on port `5620`.
* Documentation Updates:
- Expanded the README with clear instructions for loading both
HuggingFace and OneChat datasets.
- Added OneChat eval specific instructions in the corresponding README
* Fixed a bug with the existing dataset loader that was previously only
storing one document in ES.
### How to Test
Follow the instructions from the updated README:
1. Prerequisites
- Ensure you have a running Kibana and Elasticsearch instance.
- Obtain a HuggingFace access token.
- (For OneChat datasets) Ensure your HuggingFace account is part of the
Elastic organization.
2. Run the Loader
```bash
HUGGING_FACE_ACCESS_TOKEN=<YOUR_TOKEN> \
node --require ./src/setup_node_env/index.js \
x-pack/platform/packages/shared/kbn-ai-tools-cli/scripts/hf_dataset_loader.ts \
--datasets onechat/knowledge-base/users,huffpost \
--limit 100 \
--clear \
--kibana-url http://<username>:<password>@localhost:5601
```
3. Verify
- Check the logs for successful ingestion and embedding.
- Confirm the new indices in your local ES instance.
### Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
---------
Co-authored-by: Quynh Nguyen (Quinn) <[email protected]>1 parent 44b7f19 commit cf40a31
File tree
14 files changed
+655
-149
lines changed14 files changed
+655
-149
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
Lines changed: 54 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
18 | 23 | | |
19 | 24 | | |
20 | 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 | + | |
21 | 53 | | |
22 | 54 | | |
23 | 55 | | |
24 | 56 | | |
25 | 57 | | |
| 58 | + | |
26 | 59 | | |
27 | 60 | | |
28 | 61 | | |
| |||
32 | 65 | | |
33 | 66 | | |
34 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
35 | 72 | | |
36 | 73 | | |
37 | 74 | | |
| 75 | + | |
38 | 76 | | |
39 | 77 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | 78 | | |
44 | 79 | | |
45 | 80 | | |
46 | 81 | | |
47 | 82 | | |
48 | 83 | | |
49 | 84 | | |
50 | | - | |
| 85 | + | |
51 | 86 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
59 | 94 | | |
60 | 95 | | |
61 | 96 | | |
62 | 97 | | |
63 | 98 | | |
64 | 99 | | |
65 | 100 | | |
66 | | - | |
| 101 | + | |
67 | 102 | | |
68 | 103 | | |
69 | 104 | | |
| |||
73 | 108 | | |
74 | 109 | | |
75 | 110 | | |
76 | | - | |
| 111 | + | |
77 | 112 | | |
78 | 113 | | |
79 | 114 | | |
80 | 115 | | |
81 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
82 | 119 | | |
83 | 120 | | |
| 121 | + | |
84 | 122 | | |
85 | 123 | | |
86 | 124 | | |
| |||
Lines changed: 46 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 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 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
38 | 78 | | |
39 | 79 | | |
40 | 80 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
84 | | - | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
0 commit comments