Skip to content

Commit fe13bb1

Browse files
committed
Added wikipedia QNA tutorial
Added first pass at getting started with qna for wikipedia knowledge submissions Signed-off-by: JJ Asghar <awesome@ibm.com>
1 parent e1b0df7 commit fe13bb1

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
In this tutorial we will walk you through building out a new `qna.yaml` for adding new or updated knowledge to the `granite-7b-lab` model. Let's get started!
2+
3+
```bash
4+
mkdir instructlab
5+
git clone git@github.com:erictherobot/wikipedia-markdown-generator.git
6+
```
7+
The first thing we need to do is create a new directory to have a clean place to work and pull down some software. Most of the time, the easiest thing to update in the model is the Wikipedia entry, so luckily, `erictherobot` has written a helpful tool to pull down markdown versions of the articles for us.
8+
9+
```bash
10+
git clone git@github.com:<USERNAME>/instructlab-knowledge-docs.git
11+
```
12+
13+
After this, clone down your instructlab knowledge docs repository. It can be named whatever you'd like, but if you use our https://ui.instructlab.ai, you'll notice you already have `instructlab-knowledge-docs`.
14+
15+
```bash
16+
cd wikipedia-markdown-generator
17+
python3.11 -m venv venv-md-gen
18+
source venv-md-gen/bin/activate
19+
pip install -r requirements
20+
python3 wiki-to-md.py Texas_Longhorns_football
21+
```
22+
Next, we need to build a Python virtual environment and install the dependencies to get it to work. These commands cd into the directory, create the virtual environment with python3.11 (you may need to change the version of Python on your machine), activate the virtual environment, and then do the pip install the dependencies.
23+
You'll notice the `Texas_Longhorns_football` there, a Wikipedia article I wanted to pull down and create the `qna.yaml` against. You should choose whatever new knowledge you want to do here.
24+
25+
```bash
26+
cp md_output/Texas_Longhorns_football.md ../../instructlab-knowledge-docs/
27+
cd ../../instructlab-knowledge-docs
28+
git add .
29+
git commit -m "added markdown doc"
30+
git push origin main
31+
cd ..
32+
```
33+
34+
Next, we go ahead and copy the markdown into the knowledge repository, and commit it to our repository and push it up to GitHub.
35+
36+
```
37+
git clone git@github.com/instructlab/taxonomy
38+
cd taxonomy
39+
```
40+
41+
Next we pull down the upstream public taxonomy directory, and `cd` into that directory.
42+
43+
```bash
44+
mkdir -p arts/sports/american_football/college/university_of_texas/
45+
```
46+
This next step is a "best effort" for you. As the taxonomy grows, there will be some obvious choices, but if you select a tree that hasn't been flushed out yet, you'll have to do your best to think about where you'd find the `qna.yaml`. In this case, the Dewey Decimal System says sports should be under arts; this is American Football, college level with the University of Texas. Also, notice the underscores for the spaces; this is important.
47+
48+
```bash
49+
wget https://raw.githubusercontent.com/instructlab/taxonomy/main/docs/template_qna.yaml
50+
mv template_qna.yaml sports/american_football/college/university_of_texas/qna.yaml
51+
```
52+
Finally, you can pull down the `template_qna.yaml` and fill it out for the needed questions and answers. Be sure to put the context at a maximum of about 500 Tokens and questions and answers around 250 Tokens.
53+
54+
```
55+
vim sports/american_football/college/university_of_texas/qna.yaml
56+
```
57+

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ nav:
1414
- Mac Metal: getting-started/mac_metal.md
1515
- Linux NVIDIA: getting-started/linux_nvidia.md
1616
- Linux AMD: getting-started/linux_amd.md
17+
- Creating a new Wikipedia based qna.yaml: getting-started/creating_new_wikipedia_based_qna.md
1718
- Creating New Knowledge or Skills: getting-started/creating_new_knowledge_or_skills.md
1819
- Community:
1920
- Code of Conduct: community/CODE_OF_CONDUCT.md

0 commit comments

Comments
 (0)