Skip to content

Commit

Permalink
Sphinx Documentation Generation
Browse files Browse the repository at this point in the history
  • Loading branch information
arjbingly committed Mar 27, 2024
1 parent 3025d59 commit f78a34a
Show file tree
Hide file tree
Showing 93 changed files with 13,316 additions and 7 deletions.
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ dependencies = [
"deeplake>=3.8.27"
]

[project.optional-dependencies]
dev = [
"pytest",
"pytest-cov",
"mypy",
"ruff",
"sphinx",
"sphinx-rtd-theme"
]

[project.urls]
Documentation = "https://github.com/arjbingly/Capstone_5#readme"
Issues = "https://github.com/arjbingly/Capstone_5/issues"
Expand Down
20 changes: 20 additions & 0 deletions src/docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Binary file added src/docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file added src/docs/_build/doctrees/grag.components.doctree
Binary file not shown.
Binary file not shown.
Binary file added src/docs/_build/doctrees/grag.doctree
Binary file not shown.
Binary file added src/docs/_build/doctrees/grag.prompts.doctree
Binary file not shown.
Binary file added src/docs/_build/doctrees/grag.quantize.doctree
Binary file not shown.
Binary file added src/docs/_build/doctrees/grag.rag.doctree
Binary file not shown.
Binary file added src/docs/_build/doctrees/index.doctree
Binary file not shown.
Binary file added src/docs/_build/doctrees/modules.doctree
Binary file not shown.
4 changes: 4 additions & 0 deletions src/docs/_build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: eef517887ca30e256065416dae71ba9d
tags: 645f666f9bcd5a90fca523b33c5a78b7
148 changes: 148 additions & 0 deletions src/docs/_build/html/_modules/grag/components/embedding.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>grag.components.embedding &mdash; GRAG 0.0.1 documentation</title>
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=92fd9be5" />
<link rel="stylesheet" type="text/css" href="../../../_static/css/theme.css?v=19f00094" />


<!--[if lt IE 9]>
<script src="../../../_static/js/html5shiv.min.js"></script>
<![endif]-->

<script src="../../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../../_static/documentation_options.js?v=d45e8c67"></script>
<script src="../../../_static/doctools.js?v=888ff710"></script>
<script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
</head>

<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >



<a href="../../../index.html" class="icon icon-home">
GRAG
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../grag.html">grag package</a></li>
</ul>

</div>
</div>
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../index.html">GRAG</a>
</nav>

<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../../index.html">Module code</a></li>
<li class="breadcrumb-item active">grag.components.embedding</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<h1>Source code for grag.components.embedding</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;Class for embedding.</span>

<span class="sd">This module provides:</span>
<span class="sd">- Embedding</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">langchain_community.embeddings</span> <span class="kn">import</span> <span class="n">HuggingFaceInstructEmbeddings</span>
<span class="kn">from</span> <span class="nn">langchain_community.embeddings.sentence_transformer</span> <span class="kn">import</span> <span class="p">(</span>
<span class="n">SentenceTransformerEmbeddings</span><span class="p">,</span>
<span class="p">)</span>


<div class="viewcode-block" id="Embedding">
<a class="viewcode-back" href="../../../grag.components.html#grag.components.embedding.Embedding">[docs]</a>
<span class="k">class</span> <span class="nc">Embedding</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;A class for vector embeddings.</span>

<span class="sd"> Supports:</span>
<span class="sd"> huggingface sentence transformers -&gt; model_type = &#39;sentence-transformers&#39;</span>
<span class="sd"> huggingface instructor embeddings -&gt; model_type = &#39;instructor-embedding&#39;</span>

<span class="sd"> Attributes:</span>
<span class="sd"> embedding_type: embedding model type, refer above for supported types</span>
<span class="sd"> embedding_model: huggingface model name</span>
<span class="sd"> embedding_function: langchain embedding type</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">embedding_type</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">embedding_model</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Initialize the embedding with embedding_type and embedding_model.&quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">embedding_type</span> <span class="o">=</span> <span class="n">embedding_type</span>
<span class="bp">self</span><span class="o">.</span><span class="n">embedding_model</span> <span class="o">=</span> <span class="n">embedding_model</span>
<span class="k">match</span> <span class="bp">self</span><span class="o">.</span><span class="n">embedding_type</span><span class="p">:</span>
<span class="k">case</span> <span class="s2">&quot;sentence-transformers&quot;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">embedding_function</span> <span class="o">=</span> <span class="n">SentenceTransformerEmbeddings</span><span class="p">(</span>
<span class="n">model_name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">embedding_model</span>
<span class="p">)</span>
<span class="k">case</span> <span class="s2">&quot;instructor-embedding&quot;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">embedding_instruction</span> <span class="o">=</span> <span class="s2">&quot;Represent the document for retrival&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">embedding_function</span> <span class="o">=</span> <span class="n">HuggingFaceInstructEmbeddings</span><span class="p">(</span>
<span class="n">model_name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">embedding_model</span>
<span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">embedding_function</span><span class="o">.</span><span class="n">embed_instruction</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">embedding_instruction</span>
<span class="k">case</span><span class="w"> </span><span class="k">_</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;embedding_type is invalid&quot;</span><span class="p">)</span></div>

</pre></div>

</div>
</div>
<footer>

<hr/>

<div role="contentinfo">
<p>&#169; Copyright 2024, Arjun Bingly, Sanchit Vijay, Erica Pham, Kunal Inglunkar.</p>
</div>

Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.


</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>

</body>
</html>
Loading

0 comments on commit f78a34a

Please sign in to comment.