ajosh0504 commited on
Commit
62dfdfb
1 Parent(s): 43425de

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +65 -3
README.md CHANGED
@@ -1,3 +1,65 @@
1
- ---
2
- license: cc-by-3.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-3.0
3
+ ---
4
+
5
+ ## Overview
6
+
7
+ This dataset consists of ~600 articles from the MongoDB Developer Center.
8
+
9
+ ## Dataset Structure
10
+
11
+ The dataset consists of the following fields:
12
+
13
+ - sourceName: The source of the article. This value is `devcenter` for the entire dataset.
14
+ - url: Link to the article
15
+ - action: Action taken on the article. This value is `created` for the entire dataset.
16
+ - body: Content of the article in Markdown format
17
+ - format: Format of the content. This value is `md` for all articles.
18
+ - metadata: Metadata such as tags, content type etc. associated with the articles
19
+ - title: Title of the article
20
+ - updated: The last updated date of the article
21
+
22
+ ## Usage
23
+
24
+ This dataset can be useful for prototyping RAG applications. This is a real sample of data we have used to build the MongoDB Documentation Chatbot.
25
+
26
+ ## Ingest Data
27
+
28
+ To experiment with this dataset using MongoDB Atlas, first [create a MongoDB Atlas account](https://www.mongodb.com/cloud/atlas/register?utm_campaign=devrel&utm_source=community&utm_medium=organic_social&utm_content=Hugging%20Face%20Dataset&utm_term=apoorva.joshi).
29
+
30
+ You can then use the following script to load this dataset into your MongoDB Atlas cluster:
31
+
32
+ ```
33
+ import os
34
+ from pymongo import MongoClient
35
+ import datasets
36
+ from datasets import load_dataset
37
+ from bson import json_util
38
+
39
+
40
+ uri = os.environ.get('MONGODB_ATLAS_URI')
41
+ client = MongoClient(uri)
42
+ db_name = 'your_database_name' # Change this to your actual database name
43
+ collection_name = 'devcenter_articles'
44
+
45
+ product_collection = client[db_name][collection_name]
46
+
47
+ dataset = load_dataset("MongoDB/devcenter-articles")
48
+
49
+ insert_data = []
50
+
51
+ for product in dataset['train']:
52
+ doc_product = json_util.loads(json_util.dumps(product))
53
+ insert_data.append(doc_product)
54
+
55
+ if len(insert_data) == 1000:
56
+ product_collection.insert_many(insert_data)
57
+ print("1000 records ingested")
58
+ insert_data = []
59
+
60
+ if len(insert_data) > 0:
61
+ product_collection.insert_many(insert_data)
62
+ insert_data = []
63
+
64
+ print("Data ingested successfully!")
65
+ ```