Skip to content

Commit

Permalink
readme, image
Browse files Browse the repository at this point in the history
  • Loading branch information
adhurwit committed Apr 10, 2023
1 parent 4769ac0 commit d189020
Show file tree
Hide file tree
Showing 4 changed files with 275 additions and 3 deletions.
214 changes: 214 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/

# Visual Studio 2015 cache/options directory
.vs/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

# DNX
project.lock.json
artifacts/

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
_NCrunch_*
.*crunch*.local.xml

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
## TODO: Comment the next line if you want to checkin your
## web deploy settings but do note that will include unencrypted
## passwords
#*.pubxml

*.publishproj

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config

# Windows Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
AppPackages/

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
/nuget-push.ps1
/push.ps1
Binary file added 10k-q-and-a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ await kernel.Memory.SaveReferenceAsync(

public static async Task RunAsync(IKernel kernel)
{
Console.WriteLine("Hi, welcome to Microsoft's 2022 10-K. What would you like to know?");
Console.WriteLine("\nHi, welcome to Microsoft's 2022 10-K. What would you like to know?\n");
while (true)
{
Console.Write("User: ");
Expand Down Expand Up @@ -94,7 +94,7 @@ public static async Task RunAsync(IKernel kernel)
var answer = kernel.CreateSemanticFunction(FUNCTION_DEFINITION, maxTokens: 250, temperature: 0);

var result = await answer.InvokeAsync();
Console.WriteLine("MS10K: " + result.Result.Trim());
Console.WriteLine("\nMS10K: " + result.Result.Trim() + "\n");
}
}

Expand Down
60 changes: 59 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,59 @@
# SemanticQuestion10K
# SemanticQuestion10K

Ask the Microsoft 2022 10K a question and get an answer using Semantic Kernel and OpenAI Embeddings.

!(10k-a-and-a.png)


This is a sample project that shows the basics of how to ask questions to a document
- in this case Microsoft's 10K statement for 2022 - using the Semantic Kernel package.

Embeddings are used to create a semantic database. When you ask a question, the database is searched for similar sentences.
A prompt is crafted from these sentences and sent to an OpenAI GPT-3 model in Azure OpenAI Service to create an answer.


## Setup

1. An Azure OpenAI Service is required to run this project.
You can sign up for a free trial here: https://azure.microsoft.com/en-us/services/openai-service/

2. A Qdrant vector database is used to store the embeddings. You can easily run the Qdrant database in a container
and map a volume from your drive to the container.

3. There are two assembly references in this project that refer to the Semantic Kernel project.
You will need to download the project from the Semantic Kernel repo, build it, and add the references to the project.

4. I have included a text file in the docs folder which is just the 10K document saved as text - you will need this to create
the smemantic database.

5. Provide the following variables through user secrets:

`
dotnet user-secrets set "QDRANT_ENDPOINT" "http://localhost"
dotnet user-secrets set "AZURE_OPENAI_ENDPOINT" "your-azure-openai-service-endpoint"
dotnet user-secrets set "AZURE_OPENAI_KEY "your azure openai service key"
`


## Usage

There are two functions to run in the project: Parse and Question.

1. Parse: This will parse the 10K document and store the embeddings in the Qdrant database.
It expects the location of the text file (provided in the docs folder).

`
SemanticQuestion10K.exe --parse --tenkfile c:\path to file\ms10k.txt
`


2. Question: This will start a loop where you can ask questions and get answers from the content of the file.

`
SemanticQuestion10K.exe --question
`





0 comments on commit d189020

Please sign in to comment.