mirror of
https://github.com/technovangelist/videoprojects.git
synced 2026-09-10 07:16:19 -04:00
update code for 3-23 video on rag chunk size
Signed-off-by: Matt Williams <m@technovangelist.com>
This commit is contained in:
parent
0ade917579
commit
1a49040e29
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
.DS_Store
|
||||
node_modules
|
||||
175
ragembedchunklength-2024-03-23/bunjs/.gitignore
vendored
Normal file
175
ragembedchunklength-2024-03-23/bunjs/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
||||
|
||||
# Logs
|
||||
|
||||
logs
|
||||
_.log
|
||||
npm-debug.log_
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Caches
|
||||
|
||||
.cache
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
|
||||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
||||
|
||||
# Runtime data
|
||||
|
||||
pids
|
||||
_.pid
|
||||
_.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
|
||||
.temp
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
# IntelliJ based IDEs
|
||||
.idea
|
||||
|
||||
# Finder (MacOS) folder config
|
||||
.DS_Store
|
||||
30
ragembedchunklength-2024-03-23/bunjs/1-embed-by-sentences.ts
Normal file
30
ragembedchunklength-2024-03-23/bunjs/1-embed-by-sentences.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { Glob } from "bun";
|
||||
import ollama from "ollama";
|
||||
import { chunkTextBySentences } from "matts-llm-tools"
|
||||
const chunklengths = [2, 5, 8, 10, 15, 20];
|
||||
const chunkoverlaps = [0, 1, 3, 5, 10];
|
||||
|
||||
const glob = new Glob("*.txt")
|
||||
const sourcefilePath = "../../scripts"
|
||||
for (const length of chunklengths) {
|
||||
console.log(`Chunk Length: ${length}`)
|
||||
for (const overlap of chunkoverlaps) {
|
||||
console.log(`Chunk Overlap: ${overlap}`)
|
||||
if (overlap < length - 1) {
|
||||
const allChunks: {text: string, embed: number[], file: string}[] = []
|
||||
for await (const file of glob.scan(sourcefilePath)) {
|
||||
console.log(`Text File: ${file}`)
|
||||
const scriptText = await Bun.file(`${sourcefilePath}/${file}`).text()
|
||||
const chunks = chunkTextBySentences(scriptText, length, overlap)
|
||||
for await (const chunk of chunks) {
|
||||
const embed = (await ollama.embeddings({ model: 'nomic-embed-text', prompt: chunk })).embedding
|
||||
const chunkjson = { text: chunk, embed: embed, file: file }
|
||||
allChunks.push(chunkjson)
|
||||
}
|
||||
}
|
||||
const jstring = JSON.stringify(allChunks);
|
||||
// console.log(jstring)
|
||||
await Bun.write(`embedding-s-l${length}-o${overlap}.json`, jstring);
|
||||
}
|
||||
}
|
||||
}
|
||||
84
ragembedchunklength-2024-03-23/bunjs/2-generate.ts
Normal file
84
ragembedchunklength-2024-03-23/bunjs/2-generate.ts
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
import {Ollama} from "ollama";
|
||||
import { getFileNames, embeddingFileSort } from "../../sharedtools/bunjs/index";
|
||||
const similarity = require('compute-cosine-similarity')
|
||||
|
||||
const ollama = new Ollama({host: "http://mattollama:11434"})
|
||||
|
||||
type Embeddings = { text: string, embed: number[], file: string, score: number }[];
|
||||
|
||||
const rawquestions = [
|
||||
"What does num_ctx do?",
|
||||
"Where does Ollama store models?",
|
||||
"Is there a docker image for Ollama?",
|
||||
"What models work with different programming languages?",
|
||||
"What environment variable do I use to share the Ollama server to other clients"
|
||||
]
|
||||
|
||||
const questions: Embeddings = []
|
||||
|
||||
for await (const q of rawquestions) {
|
||||
const embedding = (await ollama.embeddings({ model: 'nomic-embed-text', prompt: q })).embedding;
|
||||
questions.push({ text: q, embed: embedding, file: "questions", score: 0 });
|
||||
}
|
||||
|
||||
const allEmbeddingFiles = await getFileNames(".", "embedding*.json", embeddingFileSort)
|
||||
const allAnswers: { question: string, answers: { text: string, sourcefile: string, score: number, embed: number[] }[] }[] = []
|
||||
|
||||
for (const q of questions) {
|
||||
console.log(q.text);
|
||||
const answers: { text: string, sourcefile: string, score: number, embed: number[] }[] = [];
|
||||
for await (const file of allEmbeddingFiles) {
|
||||
const embeddings: Embeddings = await Bun.file(file).json();
|
||||
for (const e of embeddings) {
|
||||
if (e.embed.length > 0) {
|
||||
e.score = similarity(e.embed, q.embed);
|
||||
}
|
||||
}
|
||||
const sortedEmbeddings = embeddings.filter(a => a.score > 0.5).sort((a, b) => {
|
||||
try {
|
||||
return similarity(b.embed, q.embed) - similarity(a.embed, q.embed)
|
||||
} catch (error) {
|
||||
console.log(`****\n${error}****\n${a.file}, ${a.embed.length} should be = to ${q.embed.length}`);
|
||||
return 0
|
||||
}
|
||||
});
|
||||
|
||||
let acc = "";
|
||||
let ecount = 0;
|
||||
for (const e of sortedEmbeddings) {
|
||||
|
||||
acc += e.text;
|
||||
if (acc.split(" ").length < 1000) {
|
||||
ecount++
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const topx = sortedEmbeddings.slice(0, ecount || 1).map(e => e.text);
|
||||
const prompt = `${q.text} The following text has been extracted from a database due to it's probable relevance to the question. Use the material if it is relevant to come up with an answer and don't use anything else. The answer should be as succinct and brief as possible to answer the question :\n\n${topx.join('\n\n')}`
|
||||
console.log(`Query to the Model: \n${prompt}\n====\n`);
|
||||
console.log(`embeddings included: ${ecount || 1}`);
|
||||
try {
|
||||
const answer = (await ollama.generate({ model: 'dolphin-mixtral', prompt: prompt, stream: false })).response
|
||||
answers.push({ text: answer, sourcefile: file, score: 0, embed: [] })
|
||||
console.log(`\nAnswer\n\n${answer}`);
|
||||
console.log("\n---\n")
|
||||
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
}
|
||||
allAnswers.push({ question: q.text, answers: answers })
|
||||
|
||||
}
|
||||
|
||||
for await (const q of allAnswers) {
|
||||
for await (const a of q.answers) {
|
||||
console.log(`Generating embedding for ${a.text.substring(0, 30)}...`)
|
||||
const embed = (await ollama.embeddings({ model: 'nomic-embed-text', prompt: a.text })).embedding
|
||||
a.embed = embed;
|
||||
}
|
||||
}
|
||||
await Bun.write(`answers.json`, JSON.stringify(allAnswers, null, 2));
|
||||
21
ragembedchunklength-2024-03-23/bunjs/README.md
Normal file
21
ragembedchunklength-2024-03-23/bunjs/README.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Rag Embed Chunk Length
|
||||
|
||||
|
||||
This is the code from the video about setting Chunk length published on March 23, 2024
|
||||
|
||||
<iframe width="560" height="315" src="https://www.youtube.com/embed/OBttxJ6FTBE?si=scuMHsPkw5YJ4UZW" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
|
||||
|
||||
|
||||
To install dependencies:
|
||||
|
||||
```bash
|
||||
bun install
|
||||
```
|
||||
|
||||
To run:
|
||||
|
||||
```bash
|
||||
bun run index.ts
|
||||
```
|
||||
|
||||
This project was created using `bun init` in bun v1.0.31. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
||||
BIN
ragembedchunklength-2024-03-23/bunjs/bun.lockb
Executable file
BIN
ragembedchunklength-2024-03-23/bunjs/bun.lockb
Executable file
Binary file not shown.
1
ragembedchunklength-2024-03-23/bunjs/package.json
Normal file
1
ragembedchunklength-2024-03-23/bunjs/package.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ "dependencies": { "matts-llm-tools": "^0.0.2" } }
|
||||
94
ragembedchunklength-2024-03-23/bunjs/similarity-threshold.ts
Normal file
94
ragembedchunklength-2024-03-23/bunjs/similarity-threshold.ts
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
// Assuming cosineSimilarity function is already available
|
||||
// import { cosineSimilarity } from './your_similarity_tools';
|
||||
import ollama from "ollama";
|
||||
import cosinesimilarity from 'compute-cosine-similarity';
|
||||
import cosSimilarity from "cos-similarity";
|
||||
import { getFileNames, embeddingFileSort } from "../../sharedtools/bunjs/index";
|
||||
import { createPrompt } from 'bun-promptx'
|
||||
|
||||
const rawquestions = [
|
||||
"What does num_ctx do?",
|
||||
"Where does Ollama store models?",
|
||||
"Is there a docker image for Ollama?",
|
||||
"What models work with different programming languages?",
|
||||
"What environment variable do I use to share the Ollama server to other clients"
|
||||
]
|
||||
let nos: number = 0;
|
||||
type Embeddings = { text: string, embed: number[] }[];
|
||||
interface TextChunk {
|
||||
sourceText: string;
|
||||
embed: number[];
|
||||
// question?: string;
|
||||
// similarity?: number;
|
||||
}
|
||||
interface QTextChunk {
|
||||
sourceText: string;
|
||||
embed: number[];
|
||||
question: string;
|
||||
similarity: number;
|
||||
}
|
||||
|
||||
|
||||
const questions: Embeddings = []
|
||||
|
||||
for await (const q of rawquestions) {
|
||||
const embedding = (await ollama.embeddings({ model: 'nomic-embed-text', prompt: q })).embedding;
|
||||
questions.push({ text: q, embed: embedding });
|
||||
}
|
||||
|
||||
const allEmbeddingFiles = await getFileNames(".", "embedding*.json", embeddingFileSort)
|
||||
const textChunks: TextChunk[] = [];
|
||||
const qtextChunks: QTextChunk[] = [];
|
||||
for await (const file of allEmbeddingFiles) {
|
||||
const embeddings: { text: string, embed: number[], file: string }[] = await Bun.file(file).json();
|
||||
for await (const e of embeddings) {
|
||||
textChunks.push({ sourceText: e.text, embed: e.embed })
|
||||
|
||||
}
|
||||
}
|
||||
console.log(textChunks.length)
|
||||
|
||||
// const approvedScoreCounts = new Map<number, number>;
|
||||
|
||||
const approvedScores: number[] = [1];
|
||||
let quit = false;
|
||||
let lowestApproved = 1;
|
||||
|
||||
|
||||
async function main() {
|
||||
for (const q of questions) {
|
||||
for (const chunk of textChunks) {
|
||||
if (chunk.embed.length === q.embed.length) {
|
||||
const similarity = cosinesimilarity(q.embed, chunk.embed) || 0;
|
||||
const similarity2 = cosSimilarity(q.embed, chunk.embed);
|
||||
console.log(`sim compare: ${similarity} - ${similarity2}`)
|
||||
const newchunk = { sourceText: chunk.sourceText, embed: chunk.embed, question: q.text, similarity: similarity }
|
||||
|
||||
qtextChunks.push(newchunk)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qtextChunks.sort((a, b) => b.similarity - a.similarity)
|
||||
|
||||
for (const qtc of qtextChunks) {
|
||||
if (nos < 5) {
|
||||
console.log(`text: ${qtc.sourceText}\n\nembed: ${qtc.embed}\n\nquestion: ${qtc.question}\n\nsimilarity: ${qtc.similarity}\n\n`)
|
||||
const approveSimilarity = createPrompt(`\n----\nIs this text relevant for the question: ${qtc.question}\n\n${qtc.sourceText}\nSimilarity is rated at: ${qtc.similarity}\n`);
|
||||
if (approveSimilarity.value?.toLowerCase() === 'n') {
|
||||
nos += 1;
|
||||
} else {
|
||||
nos = 0;
|
||||
lowestApproved = qtc.similarity;
|
||||
}
|
||||
} else {
|
||||
console.log(`lowest approved is: ${lowestApproved}`)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
main();
|
||||
console.log(qtextChunks.length)
|
||||
30
scripts/aboutthementors.txt
Normal file
30
scripts/aboutthementors.txt
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
what if you had an in with your favorite dream mentors? Maybe you could just type in a question and within seconds, faster than an email, you see one of those mentors typing out their answer just for you. "I have a business idea about selling evil scented soaps to dogs". And seconds later Gary V starts responding with his thoughts on this idea. A few seconds after that, Sheryl Sandberg chimes in and gives her take. And then for a little comedic relief, Owen Wilson closes out the conversation. If I told you i could make that happen, would you stay till the end of this video? well, I can't really say that, but I came up with a demo app that approaches that idea in an interesting way and you can have a variation of your real life dream mentors waiting for your questions.
|
||||
I first showed this recently at an event in San Francisco called Chat8VC, hosted by the venture capital firm 8VC. Let's try it right here. "I have a business idea about selling evil scented soaps to dogs. What do you think?". And within seconds, I start getting responses from three random well known people. So what is actually going on here?
|
||||
|
||||
At the heart of it is Ollama, an open source project I am a maintainer of. Ollama is the easiest way to run large language models, or LLMs, locally on your laptop, on Mac, Linux, and Windows. I can just run 'ollama run llama2' and start asking questions that I might have asked ChatGPT before but maybe I don't feel like having my sensitive info finding its way into the model.
|
||||
|
||||
The way we get the personalities of individuals to show up is to create a special prompt. An LLM has been trained with the content of the Internet to understand how words go together depending on what we are talking about. We have to give the model a system prompt and a prompt to guide the LLM to give the kind of answers that we need.
|
||||
|
||||
I tried different approaches to getting a reliable personality. I tried giving it examples from interviews the person had given in the past. I tried with a lot of examples and with just a few. And actually, the less info I gave it, the truer the outcome became. But it still wasn’t that great.
|
||||
|
||||
Then I stumbled on a different idea, to come up with a short biography of the user, along with a discussion of the verbal tics and mannerisms that show up when the person speaks publicly.
|
||||
|
||||
The first few attempts at this were using handcrafted bios, but I quickly realized that the Stable Beluga 70 billion parameter model did a good job of coming up with the info I required. The only downside is that it's slow, and I want the model to respond quickly, so I need to use a smaller model, at runtime. Llama2 7b will be better for that.
|
||||
|
||||
So let's take a look at what a model is. The most common site for finding large language models is Hugging Face. This is a great index for Machine Learning and AI experts who want to do research. It's not the best site for folks just wanting to use the models in their normal lives. But let's say you have found a model that works and you download it. To use it in most tools, you need to find a system prompt and a template. Without the template and the system prompt, the model, or more specifically, the model weights alone, are useless. So really a complete model should be the weights combined with the system prompt and template, as well as some parameters. And that's what models are when you use Ollama.
|
||||
|
||||
To create a model, you build a modelfile, which is much like a Dockerfile. We start with a source model. This is normally going to point to one of the models in the Ollama library. Then you can add some parameters if you have any. Next is the Template. This formats your question and the system prompt in a way that the model will understand so you don't get back garbage. And finally include the system prompt that tells the model how to respond.
|
||||
|
||||
Any of the instructions included in the parent model will be inherited by your model unless you override them by including them in this file.
|
||||
|
||||
Ok, so let's build a new model for a new mentor. We will build it for Sheryl Sandberg. I have a script that basically calls on the Stable Beluga model to generate a bio for this person and automatically outputs it to a new Modelfile. Let's take a look at what got generated. We see that as of the training for the Stable Beluga model, which is based on Llama2, Sheryl Sandberg was still the COO of Facebook, but she isn't anymore. So we need to go in and tweak, but it's a good first draft.
|
||||
|
||||
I can convert this into a model by running 'ollama create mattw/sherylsandberg'. 'mattw' is my namespace, so it's where I upload all my models. You can find them at ollama.ai/mattw. I can now test the model by running ollama run mattw/sherylsandberg. Finally ollama push mattw/sherylsandberg to post it to the library.
|
||||
|
||||
Now, I'll update my code for my mentors to include Sheryl and run it on a question: 'What is the best way to meet people at an event'. My code picks three people at random to answer the question. the first person just sees the question. The second person sees the first answer and the third person sees the first two answers. Sometimes they answer and refer to the other folks in the conversation, and sometimes they don't.
|
||||
|
||||
I find this a lot of fun to play with. Is it perfect? No way! Will you confuse the AI's for the real thing? only if you are drunk. Is it fun to show at my presentations? Absolutely.
|
||||
|
||||
So I hope you have fun with it. It should find its way into the examples in the Ollama repo really soon. Let me know what you think of it, and let me know in the comments what else you are doing with Ollama. If you don't know about ollama yet, you can find out about it at ollama.ai.
|
||||
|
||||
thanks so much for watching. goodbye
|
||||
21
scripts/airenamer.txt
Normal file
21
scripts/airenamer.txt
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
You have just taken some photos with that new camera of yours. It can be a lot of fun taking the pics But then you bring it home and offload it to your computer. And now you have hundreds, or thousands of images with horrible names. How do you solve this? Well, you could just use AI to name them like this. It runs in seconds completely locally on your machine; your images never get shared online, until you are ready to do so. Want to see how this is done?
|
||||
|
||||
Let's check out the code I wrote to build this. Even if you know nothing about Typescript or more specifically, Deno, it should be pretty easy to follow. Or if you just want the executable for mac, windows or linux, then wait till the end of the video and I'll show you where to get it.
|
||||
|
||||
Here is the main function. I get the current working directory and then iterate through all the files. If a file is a jpg or png, then I am going to get a base64 encoding of the file. More about why in a second. Now I call getkeywords. This returns a promise of an array of keyword strings.
|
||||
|
||||
So lets scroll up to the definition of getkeywords. I am using the generate endpoint for ollama which you can learn about here in the repo docs in the api.md file. You POST to that endpoint and pass it the body which needs to be a string of the json. So up above, I created the body that actually gets sent to the endpoint. I specify the model. I am using llava:13b, which is a 13 billion parameter model. Since I am going to use the output of this call in a function, I want to output JSON. Then in the prompt, I describe what I want. "describe the image as a collection of keywords". Output in JSON format is important when we want to format json. You need to specify it in both places. And then its helpful to include the schema you want to use for your json.
|
||||
|
||||
Then because I am using a llava model, I need to give an array of base64 encoded images. I think it only understands one image for now, but it still needs to be an array. Then since the output of the model isn't for human consumption, I set stream to false. That just makes it easier to deal with.
|
||||
|
||||
Now I can get the JSON from the response, parse it, and then keywords is just the array of keywords.
|
||||
|
||||
The next line in my main function is to take that array of keywords and an extension and generate a file name. This starts with an array map that replaces spaces with underscores, then joins the keywords with dashes, and attaches an extension. And then we are done there.
|
||||
|
||||
The last step is copyfilesync. This just takes the original file and copies it to our new filename.
|
||||
|
||||
If you want to take a look at the code, you can find it on my github right here. Or if you just want the executable to try on your own images, then you can find it in the releases section. You will probably want to rename the download to something like airenamer and ensure that its executable. And of course, you need to have Ollama installed on your system and have the llava:13b model pulled. Oh, and you also might want to ensure that your images are backed up, just in case.
|
||||
|
||||
I hope you have as much fun with this as I had writing it.
|
||||
|
||||
Thanks so much for watching, goodbye.
|
||||
11
scripts/chatapi.txt
Normal file
11
scripts/chatapi.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Hey there, it’s matt, one of the maintainers of ollama. I wanted to introduce you to the chat api endpoint. One of our goals has always been to make the best tool for users and developers working with ai. So the main way to generate an answer from a model has always been the generate endpoint.
|
||||
|
||||
If you don't have Ollama yet, you can find it at ollama.ai. Click the download button and install it. You will get a CLI UI and a server that responds on a set of RESTful endpoints.
|
||||
|
||||
es input, then add that to a message and send all the messages to the chat function. that function outputs a message to the list of messages and I repeat. The chat function makes a call to the endpoint, passing the model and the messages. Then i cycle through the responses pulling out the content of each message which gets added to the output and printed to the screen. The full message then gets returned to the main function.
|
||||
|
||||
And that’s it. You can see that working with the chat endpoint is easy, but maybe a bit more work than the generate endpoint. that extra work comes with the benefit of being able to do more with the history. For instance you can decide to keep the last 5 messages in full and to summarize anything older. or maybe you keep any short message and summarize the outputs with more than 100 words. Some folks are also finding that it allows alternate techniques like Chain of Thought prompting easier. I think that’s pretty cool.
|
||||
|
||||
I can't wait to see what you do with it and hope you will share it with me in our discord, which you can find at discord.gg/ollama
|
||||
|
||||
Thanks so much for watching. goodbye.
|
||||
27
scripts/choosingamodel.txt
Normal file
27
scripts/choosingamodel.txt
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
You just installed Ollama on your computer and you have played around with the llama2 or mistral model. And now you want to try out some other models and you aren't sure which to use. What are your options?
|
||||
|
||||
Well, the best place to learn about other models is the Ollama Library. Just go to ollama.ai and navigate to the Models link. This is a list of all the models available on the official library. You can sort this list by Featured, which is ordered by what the team thinks is best for most. By the most popular, which looks at which models have been downloaded the most, in the last few weeks. And by most recent, which is how you can discover the newest models.
|
||||
|
||||
One of the recent models to be added is llama-pro. This is a model from Tencent Applied Research Center and is apparently really good at general language as well as programming and math. The next step is to look at the tags page. This lists the tags available for that model, which is everything after the colon in the name.
|
||||
|
||||
At the top you will usually find the 'latest' tag. Despite the name, this actually has nothing to do with what is the latest version. It's more about what is the most popular variation. If you leave off a tag, Ollama will use the 'latest' tag. Under the latest tag name, you can see the size of the model, the start of the sha256 digest, and the age of the variation of the model. To the right is the command you would run if you want that version.
|
||||
|
||||
Now take a look at the digest. Notice that for this model you see fc5c0d744444. Then notice that you see the same digest for the instruct tag, and the 8b-instruct-q4_0 tag. This means all three of those tags are aliases for each other. An instruct model is usually trained to work with a chat interface and will respond to you in an expected way. The alternative on this model is text. Text models tend to be more of a base model that you could train yourself, if you knew how to do it.
|
||||
|
||||
This model just has an 8 billion parameter option. This means that it should fit in about 8 gb of ram. It will actually take closer to 4 gb, but your os needs some space and the context needs more. So 8 is a good safe number. In most cases, the number of parameters is a good place to start with how much memory is required, but its not directly correlated. I'll make a video in the future that deals with understanding how memory works with these models.
|
||||
|
||||
Then there are a whole bunch of tags that use the letter q followed by a number and sometimes a k. These refer to quantization. I'll create a video that deals with this soon. But essentially quantization is a type of compression. q4 means that the 32bit floating point numbers in the model have been converted to 4bit integers. At this point, that sounds a bit like magic, but trust me, it works really well. q4_0 is usually the model you want to start with.
|
||||
|
||||
Now lets click on the latest tag. here we can see information about the model. probably the most important info here that you might refer to later is the layers of the model.
|
||||
|
||||
In Ollama, a model is a little different from what most other tools call a model. Usually a model is just the model weights and nothing else. But they are useless without a system prompt and a template. So Ollama puts all of that together. Each component is a layer in the model, much like docker's layers. On this tags screen you can see the different layers. First we see parameters. In this case we have a list of stop parameters which tells ollama to ignore everything after it sees those phrases.
|
||||
|
||||
Then there is a template. This tells ollama how to format your prompt in a way the model will understand. This is determined based on the training process the model developers used.
|
||||
|
||||
Let's go back to the top level. Now that you know how you can find a model, which model do you choose? Well that is a harder question to answer. There is a lot of overlap when it comes to what the models do. And there are benchmarks that let you know how a model performs. But those benchmarks are useless unless all your questions are included in the benchmark. So the best way to know which model to try is to just try all the models yourself and see what works well for you.
|
||||
|
||||
I have a tool that I worked on that helps you determine what is the best model for your questions. Soon I will share that, along with a video that explains it here on this channel. Be sure to subscribe to be notified when that comes out.
|
||||
|
||||
And that’s how you can find the models we support. If you have any further questions, let me know in the comments below.
|
||||
|
||||
thanks so much for watching. goodbye.
|
||||
44
scripts/convertingamodel.txt
Normal file
44
scripts/convertingamodel.txt
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
How often have you asked out loud, I wish I had an AI model that responded only in emojis? Like every day right? I know. And for some reason the team building Ollama has not listened. Insanity. So we are going to fix that today. You and me. And in the process you will learn how to convert and quantize a model.
|
||||
|
||||
It's not hard but it also takes a bit of effort to get it going... and maybe some false starts. And it doesn't always work.
|
||||
|
||||
So the first step is finding the right model. Lets go to HuggingFace. Up top, I'll search for emoji and then show all the models. I don't want to create an emoji, that would be silly. I want to do text generation, but with emoji. So select Text Generation over on the side. And the first result is OpenHermes Emojitron 001. Perfect.
|
||||
|
||||
Scroll down and this seems to be exactly what we want. Exactly what everyone NEEDS. Now go to the files tab and click on the config.json file. Notice that architecture is MistralForCausalLM. That’s good. That’s one of the architectures supported.
|
||||
|
||||
We should download the model now. But I have always had trouble just downloading the files the normal way with git. So I really like HuggingFaceDownloader by "boda ay"? You can grab the executable for the releases and get it installed. I have a folder off my users root called bin so I just throw it in there.
|
||||
|
||||
ok, so go to the repo on huggingface and click the copy icon next to the repo name. And now go to whereever you want your models to be downloaded to and run `hfdownloader -s . -m` and paste the repo name. Press enter.
|
||||
|
||||
Those files are downloading so now lets get the conversion process working. Make sure docker is installed and running on your system. Then in a different terminal, run `docker pull ollama/quantize`.
|
||||
|
||||
How's the hugging face downloader process going. We need to wait for the model to download, so I will speed on to that being done.
|
||||
|
||||
So here we are in the folder we ran that command in. Move into the directory created for the raw model. We need to run `docker run --rm -v .:/model ollama/quantize`. This is not going to work, but it shows us something we need. Docker run will run an image to create a new container on your system. `--rm` removes the container once the process is complete. `-v .:/model` tells docker to mount a volume. Take what ever is in the current directory, represented by the dot, and mount it in the container as `/mount`. `ollama/quantize` is the image we want to run. And then the command that is being run inside the container takes 2 parameters. First, `-q` specifies the quantization. And that’s why I wanted the command to fail. We need to know which quantization to use. The fastest to run and the best compromise in performance and quality is usually `q4_0`. So run that `docker run` command again, adding `-q q4_0 /model` to the end. I'll try to remember to put the full command in the description, but I am sure someone will call me out on forgetting.
|
||||
|
||||
If everything works and the model is configured correctly then we should see a lot of activity. The model is first being converted to GGUF format. And then it's being quantized to 4 bit. Quantization simply means that the 7 billion 32bit floating point numbers are being quantized to 16 bit integers. To visualize this I need some cool graphics and I am working on that before making a video about quantization.
|
||||
|
||||
There are now 2 new files here. f16.bin which is the converted model, and q4_0.bin which is the 4bit quantized gguf model file. This second file is often referred to as the model weights, but its kinda useless without a template, possibly a system prompt, and maybe some parameters. We can make a guess about the template but it's best if we look in the Hugging Face readme. Their isn't a standard way of showing this, so there may be some sleuthing we need to do. Down here at prompt format it says "OpenHermes-Emojitron-001 uses ChatML as the prompt format, just like Open Hermes 2.5.It also appears to handle Mistral format great. Especially since I used that for the finetune (oops)". I wish they put the format in here, but now we have to figure out what mistral uses since that’s what the fine tune was based on. The easiest way to do this is to go to ollama.ai, click Models, then search for mistral. Now click tags and choose the first one. scroll down and we see the template.
|
||||
|
||||
`[INST] {{ .System }} {{ .Prompt }} [/INST]`. All of those brackets are very important. So now lets open a code editor. I am using vim just to keep it simple. The first line is the FROM instruction: `FROM ./q4_0.bin`. Next we need a template. I'll copy that template from the ollama.ai site and paste it in here. And that’s the minimum we need. So exit out and create the Model: `ollama create emojitron`. Since we are in the same directory as the Modelfile, and it's called Modelfile, we don't need to specify it.
|
||||
|
||||
Now `ollama run emojitron`. hi. and we got an emoji, followed by a control phrase im_end. "what is the meaning of life". We get some emojis and that im end again. ok. lets get out of here and edit that modelfile again. I'll copy the "im end" text so i can paste it in. Now add `parameter stop` and paste in the text. Exit out and run the create command again. Now do ollama run again.
|
||||
|
||||
"what is the meaning of life". cool. "create a recipe for spicy mayo". nice. "what is a black hole". Oh yeah, neal degrasse tyson, your job is mine. And now for the biggest challenge that some of us will ever face. "how are babies made. explain like I am 5". awesome. I love that "baby comes soon" that you see at the end.
|
||||
|
||||
That worked perfectly. It doesn't always work perfectly. We used a docker image to do the conversion and quantization, but that was removed from the docs recently. Maybe it doesn't work as reliably for most models. So there is the older process which is more manual. It involves cloning the ollama repo and using the llama cpp submodule, then creating the quantize command and running the python scripts yourself. So that means getting a working python environment which is always a pain in the butt. You can find the instructions for the process here in the repo and scroll down to importing pytorch and safetensors. But first check the architecture in the config.json file. Unfortunately i don't think the architectures supported is actually documented. But you can probably guess some of them.
|
||||
|
||||
Sometimes the output is going to complain about something and suggest a command line parameter. That won't work using the docker method so you will have to manually run the steps. I have had that a few times with needing to pad the size of something. Add the parameter and it worked just fine.
|
||||
|
||||
The next challenge is always the template. Sometimes model makers state the template, but often they just seem to assume you will know. And so you have to try a bunch. You can often figure out the base models then either look up their readmes or look at the model on ollama.ai. Then, get the formats for llama2, mistral, open hermes, and others and just try each one, hoping to get a match.
|
||||
|
||||
So now you have a model and you want to share it with others, right? You will need a namespace to do that. If you don't already have one setup, then go to ollama.ai and click the sign in button. Below your credentials there is a "create account" link. enter your email, a username, and a password. Make sure you set the email address to something you will have access to forever. Using a work account is great until you don't work there anymore. The username I think has to be 3 or 4 characters or more. There is only one exception to that....mine. Once you have done that you will see the instructions to add your public key to Ollama. This looks like an SSH key but it isn'. Make sure you grab the public key from your .ollama directory.
|
||||
|
||||
Next we need to rename our model because emojitron doesn't have a namespace. so `ollama cp emojitron` and then your namespace, which for me is just the letter `m`. and then `/emojitron`. If you rename yours to m/emojitron, you won't be able to push it because you don't have my ollama key.... I hope.
|
||||
|
||||
Now you can push the model. `ollama push m/emojitron`. And the model will upload. This takes however long your Internet connection takes. Once that is done, you should edit the short description for the model. And then Edit the longer description for the model. Now share with the world your incredible achievement, win incredible glory, and retire tomorrow with your share of the worlds money. Simple.
|
||||
|
||||
let me know if there is anything else you would like me to cover in these videos. I love making them and can't wait to see your comments down below pointing me to your new models.
|
||||
|
||||
Thanks so much for watching. Goodbye.
|
||||
|
||||
29
scripts/envvarsonwindows.txt
Normal file
29
scripts/envvarsonwindows.txt
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
OK, windows is out and so now folks are starting to play with it. And they are hitting some interesting edge cases. Thankfully a lot of those cases already have solutions. So one of them is around where the models go.
|
||||
|
||||
Normally they would go under the users home directory, then .ollama, then models. I have a video that shows where things are stored. That was for the mac and linux, but nothing changes on windows. Everything is in the same place as before.
|
||||
|
||||
But in some edge cases, folks have run out of space on their c drive and added another drive to their system. Now they want Ollama to save those models to d or e or some other drive. How do you do that. Well, the solution is the same as on mac and linux, but maybe even easier to solve on Windows.
|
||||
|
||||
It's all about environment variables. And the environment variable we need is OLLAMA_MODELS. So go to System Properties and click the button at the bottom labelled Environment Variables. There are two sections here and we want "System" Variables. Click the New button and add OLLAMA_MODELS for the name. Now click the browse button to find the right directory anywhere on your system. When you are done, close that out. Now Ollama is probably already running, so you need to quit it. To do that, click the icon in the task tray and then restart it by running ollama over here.
|
||||
|
||||
Now we can open the command prompt and run ollama pull mistral and we should see the model blobs start to show up in our new directory. That said, it sometimes didn't work for me. I don't know if its just a slow machine or what. But I killed ollama and restarted it again and the second time it took, and files started showing up in the expected folder. You know, maybe I didn't give it enough time to fully quit before I started it again and that's why it didn't work the first time. So give it a sec before starting and see if that works for you.
|
||||
|
||||
If you want the files to start showing up in the original location, simply deleting the environment variable isn't all you need to do. If you want to keep your machine up and running, then set OLLAMA_MODELS to the new location and you are set. OR delete the environment variable and reboot. I deleted it and files kept going into the old ...new directory.
|
||||
|
||||
Maybe this is because I am relatively new to the current systems as I haven't really used Windows since I worked at Microsoft a couple of decades ago. I was there in the time of Brian Valentine running Windows.... XP just came out. Bill and Steve were still there... Anyway, this is what worked for me. Hopefully you find it useful.
|
||||
|
||||
If you have any questions about this or any other topic about AI and Ollama, life in general, and everything in between, ask away in the comments below.
|
||||
|
||||
Usually I don't ask you to like and subscribe because I never do that on videos I watch. But I did ask on a fairly recent video, for some reason. Someone commented that when i did, the button wiggled a bit. So let's try an experiment... for science. I'll say it and we can see if it wiggles. like and subscribe to see more videos as they come out. did it work? hmmm, maybe you need to click the button. Do it...you know, in the name of science.
|
||||
|
||||
Well, anyway, I appreciate everyone who does it. Thanks so much for watching. goodbye.
|
||||
|
||||
|
||||
---
|
||||
short
|
||||
|
||||
Windows is out and now folks are starting to play with it. In some cases, folks want Ollama to save models to d or e or some other drive. How do you do that. Well, the solution is environment variables. And the environment variable we need is OLLAMA_MODELS. So go to System Properties and click the button at the bottom labelled Environment Variables. There are two sections here and we want "System" Variables. Click the New button and add OLLAMA_MODELS for the name. Now click the browse button to find the right directory anywhere on your system. When you are done, close that out. Now Ollama is probably already running, so you need to quit it. To do that, click the icon in the task tray give it a sec before starting and then restart it by running ollama over here.
|
||||
|
||||
Thanks so much for watching. goodbye.
|
||||
|
||||
|
||||
37
scripts/functioncalling.txt
Normal file
37
scripts/functioncalling.txt
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
Function calling. This has to be the worst name for a feature. Every company I have worked for had marketing folks who had no idea what the feature was and called that feature something that sounded cool but had nothing to do with the feature.
|
||||
|
||||
So if you know what this feature is, pretend you don't and think of what function calling should mean. I would think that function calling in a model means that the model calls functions. And that would be a great feature for a model to have, but the model has no ability to call functions when you use function calling. Function calling is all about controlling the format of the output from the model. When you get the response in a format you expect, then you can reliably call a function. But you are calling the function. The model is not. Or even if we expand it out to the company that created the feature, openai does not call the function, your program that calls the openai api calls the function.
|
||||
|
||||
Don't believe me? Let's go to the OpenAI docs and go to function calling. Scroll down to this 4 step process. Step 3, YOU parse the string output of the model into json, then YOU pull out the values then YOU call the function. I am great with that. It's an awesome feature. It would just be better if the name was accurate.
|
||||
|
||||
OK, so with that settled let's look at how the openai api achieves function calling. One of the important steps is to inform openai about your functions. What the function does isn't relevant. This is just how you let the model know about the schema the output should stick to. The rest of this example is using the chat api to ask the model a question. Then the chatcompletion message shows us the output string that we format to json.
|
||||
|
||||
Now let's move on and look at how to achieve this in Ollama. The feature you will find in the docs is referred to as format json which is a bit more descriptive about what is going on. There are 2 requirements to get this working, and one bonus that makes it work even better. You can do it in the API or even in the CLI if you are scripting something in bash.
|
||||
|
||||
Let's use Python for this one and I am not going to use the sdk just to keep things more translatable to other languages. We can start with importing requests. Now we can define a payload that we are going to send to the chat endpoint. This includes a model and an array of messages. We don't need to include a system prompt, since there is already one in the model in Ollama. So role user, and content, what is the capital of Germany. Now set response to a post request to http://localhost:11434/api/chat and setting our payload to the json. Now print out the json from the response.
|
||||
|
||||
To get a streaming response from python we need to iterate through the response. So "for message in response.iter lines", then parse the json and print message.content. Let's add "end set to nothing", to put everything on one line, unless the response includes a newline.
|
||||
|
||||
python fc.py and we get something saying that the capitol of germany is berlin. Awesome. Now lets make this a touch more dynamic by taking the country as a command line argument. I'll import sys and then set "country" to "sys.argv 1". Then change the content in the payload to be an f string and include country in curly braces. python fc.py France, gets us Paris.
|
||||
|
||||
Now lets say we want to find the capitol of that country and then calculate the distance between Bainbridge Island, where I live, and that city. So for that we can use the haversine package which takes the decimal latitude and longitude of two places and calculates the distance between them. So let's change our question to What is the decimal latitude and decimal longitude of the capitol of {country}.
|
||||
|
||||
And run python fc.py portugal and we get some coordinates. But the current format of the response changes as we use it. Plus, having to parse the string looking for coordinates will get annoying. The first thing we can do is ask the model to respond as json. let's add it as a new system prompt. We can just add this to the top of our messages. Role is system and content is "You are a helpful assistant. The user will enter a country name and the assistant will return the decimal latitude and decimal longitude of the capitol of the country. Output in JSON." And we can change the user content to just country.
|
||||
|
||||
So this is a good start, but notice that we have an explanation of the json format, and sometimes the key names are different. So add format json to the payload and things are a lot better. But if you try it enough you may still see the key names change. So we need to provide a schema to the model. This is the purpose of the function block in the openai api.
|
||||
|
||||
For the schema, I am giving a key, then type and description. Since I need the city, and coordinates, I specify one for each. And I am using the words lat and lon to show that my schema is being respected. If you run the program a few times, you will notice that its not the most precise way of getting the latitude and longitude. But its just a simple demo.
|
||||
|
||||
Now if the model sometimes responded with something that wasn't in the schema, I would do a few shot prompt. Let me show that just so you can see an example. There is a user and I also give the assistant's response.
|
||||
|
||||
For a json response, since we need to get content out of it and we can't do anything until its complete, we should disable streaming. Then we can set cityinfo to the json string in the message content. Now we can call haversine with my latitude and longitude and the coordinates of the capitol city and get a distance.
|
||||
|
||||
If you run this a few times, you may notice that the distance isn't always consistent. Asking a model for latitude and longitude isn't a great use of the system. We can set the temperature to 0 to try to get it to be more consistent but it may still be different from what you get with a Google search. And that depends on where exactly both systems put the dot that says this is the spot that represents the capitol of whichever country.
|
||||
|
||||
Hopefully you now see how you can use format json to get a consistent output from a model. Because that's all the terribly named feature of function calling does. It gives you consistent output from the model, so that you can call a function with the data. Which is a very cool thing to be able to do.
|
||||
|
||||
Function calling using the new openai compatible api isn't available yet at the time of recording so you need to use the native ollama api for this. I don't think anyone is going to want to do it the openai way, because its just a lot more complicated and doesn't offer any benefit. But it has openai in the name so maybe that's good enough to justify suffering through the pain.
|
||||
|
||||
What do you think. Is Function Calling, I mean format json, an important feature for you? Are you using it today? let me know down in the comments below. And if there is another feature you would like to see let me know about that in the comments. When I started this latest focus on the channel a month ago, I had a simple list of about 50 ideas for future videos. But your comments over the last few weeks have upped that to well over 100. Keep them coming though because there are so many good ones I never thought of.
|
||||
|
||||
thanks so much for watching this one. goodbye.
|
||||
32
scripts/howwestorethefiles.txt
Normal file
32
scripts/howwestorethefiles.txt
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
hey there, its matt williams from ollama. One of the questions we get every now and then, including just today, is about how we download the models and how we store them on the file system. So lets go over that.
|
||||
|
||||
When you install ollama, it creates a .ollama directory in your home folder. That has a Logs directory and a Models directory. Inside Models is Manifests and Blobs. Manifests hold the descriptions of the models and Blobs holds the files with the actual content. So go into manifests and you will find a directory for each source, and probably the only one is registry.ollama.ai. Then go to library. Ok so i have two directories here, orca and sentiments.
|
||||
|
||||
Lets step back a bit and see how i got here. first i ran 'ollama pull orca'. this pulled the orca model and stored it on the local filesystem. Then I went to the examples directory in the ollama repo that I cloned to my machine. Then I ran 'ollama create sentiments -f ./sentiments/Modelfile'. So you might think that sentiments was created locally so shouldn't be stored in the same folder as orca. Well, every model goes into a server then a namespace. This will make more sense when we open our registry to pushes and we have alternate registries.
|
||||
|
||||
But if you wanted to have sentiments stored somewhere else, you can specify a host, slash namespace, slash modelname. so localhost, slash matt, slash model. or company website, slash user name, slash model.
|
||||
|
||||
Lets go back to the registry/library folder. we have our two models. now take a look in orca then open latest. this manifest defines all the layers that make up a model. You can see there is a layer for the actual model, a layer for the template, and a layer for the system prompt. The model file is a huge binary file, so we won't open that one. But lets look for the template file.
|
||||
|
||||
I'll copy the full digest value for the template. And now in a different terminal I will go to .ollama/blobs. cut and paste the digest value. and now you can see the full template. in fact lets run orca and then slash show template. It’s the same thing.
|
||||
|
||||
Back in the manifest we can see a system layer. we can go through the same steps and again in both places they show the same info.
|
||||
|
||||
so lets go up from orca to sentiments and take a look at that latest. notice that this one also has a model, a system prompt, and a template. but before we go far with this one, lets also look at the source modelfile that you can find in the examples directory in the repo. Actually this isn't the modelfile in the examples anymore. as i made this video i realized I made a mistake which I have since corrected. and i will tell you more about that in a second. There are just two instructions here, a model, and a template.
|
||||
|
||||
Now back in the sentiments/latest file we can see that model and system share the same digest as the orca/latest file and so we can see they share the same actual files. We only store one copy of the orca model weights despite having two models that reference it. The sentiments modelfile doesn’t mention the system prompt. so where did it come from?
|
||||
|
||||
Well since sentiments uses the orca model, we inherit all the instructions that aren't overridden in the sentiments modelfile. This can be a bit confusing and something to look out for.
|
||||
|
||||
In this case, its just confusing for the user. The system prompt doesn't get used so there is no harm, but if someone else uses sentiments as their base model, they may get frustrated that their own system prompt doesn't work.
|
||||
|
||||
So lets fix this. Ill remove the sentiments model with the ollama command. You probably wont need to do this in the future, but I want to ensure everything stays clean in the blobs folder. Now the System prompt is its own instruction which is referenced in the Template.
|
||||
|
||||
So I will run the create command again, and take a look at the updated manifest. Now the manifest uses our new system prompt and a new template.
|
||||
|
||||
When you run ollama pull orca, ollama reaches out to the registry and finds the orca manifest and downloads it. Then it finds each layer and if the layer doesn't already exist in blobs, it will download each of them. And that’s it. As you can see, although the files look a bit cryptic, it turns out it's pretty easy to figure out.
|
||||
|
||||
I hope you found this useful. If you run into any other questions, ask them in the discord. we can get the answer to you and maybe I'll create another video or at least expand on the documentation.
|
||||
|
||||
Thanks so much, bye
|
||||
20
scripts/keyboardcontrol.txt
Normal file
20
scripts/keyboardcontrol.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
When using the Ollama CLI or repl, there are now keyboard shortcuts you can use to move around the prompt. These can be useful when leveraging the previous prompt but you need to change something. On Linux, the shortcuts should work as expected, but its possible that on Mac, they may not work as designed. Let's take a look at why this happens.
|
||||
|
||||
|
||||
To get to the REPL, run `ollama run` and then the modelname. llama pro just came out, so i will use that one. To find the list of shortcuts, type /? and then shortcuts. You can see there are a few options here. ctrl a and ctrl e move to the beginning and to the end of the line. This can be a little confusing. I think anytime you see line or sentence, really think of it as 'prompt'. So ctrl A moves to the beginning of the 'prompt' and ctrl e moves to the end of the 'prompt'.
|
||||
|
||||
Next comes alt b and alt f for moving back and forward by a word. On my mac, this didn't work. If you are seeing a similar issue, then this might be the way to fix it for you. If you are using the standard mac terminal, then open preferences. Navigate to profiles and then whichever profile you are using. Go to the keyboard tab and then check the checkbox for 'use option as meta key'.
|
||||
|
||||
If you are using iterm, bring up preferences, then profiles then the keys tab. Then the sub tab for general. You can see there are settings for the left and right option key. Mine were already set to Escape plus. But my left option key had 'Apps can change this' enabled. Disable that.
|
||||
|
||||
Now go back to the terminal and alt (or on the mac, option) b and f work as expected.
|
||||
|
||||
Finally there is ctrl k and ctrl u to delete everything before or after where the cursor is. It says sentence as of this recording, but just think of it as the entire prompt to or from the cursor.
|
||||
|
||||
The last 3 options are ctrl L to clear the screen, ctrl c to stop the model from responding, and ctrl d to quit the repl.
|
||||
|
||||
If you are using a different terminal and you are having similar problems, Look around for any preferences that deal with the alt / option key. that may be the 'key' to the solution. Maybe even include what you did in the comments below.
|
||||
|
||||
Well, hopefully this is useful for you. If there is anything else you would like to see, let me know in the comments below.
|
||||
|
||||
Thanks so much for watching, goodbye
|
||||
25
scripts/llava.txt
Normal file
25
scripts/llava.txt
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
Hey there, it's matt, one of the maintainers of ollama. Recently we added support for the llava models in Ollama and they are pretty cool. llava stands for large language and vision assistant models and means that you now have the ability to incorporate vision into your ai applications. You can give the model a prompt and an image and it will do a pretty great job of recognizing what is in the image. How good? well lets look at a few examples.
|
||||
|
||||
Ill start by running 'ollama run llava'. Now you will need a recent version of ollama to get this to work, and you can install ollama at ollama.ai.
|
||||
|
||||
Now ask what does this image show and drag an image over. "shows a beautiful view of the ocean and surrounding hills...sun setting in the distance...appears to be a picturesque landscape that may offer a relaxing spot...". And here is the image. It's close. Its actually a house we rented in Tiburon just north of sf, but it’s a good description.
|
||||
|
||||
Lets try again. " man with glasses wearing a black tshirt and grey hoodie." Not quite a hoodie, but its me and i do have a black tshirt.
|
||||
|
||||
Heres another. "group of 3 llamas standing together" starts out right. "desert landscape?" well, maybe not.
|
||||
|
||||
"a colorful bird flying close to the waters surface". Yeah, that seems to match the image.
|
||||
|
||||
"interior of a car, with drivers side view. ... car is located on a dirt road surrounded by trees". This one is pretty amazing.
|
||||
|
||||
"majestic snow capped mountain". yup, pretty much dead on.
|
||||
|
||||
So, often the descriptions it comes up with are really good. but sometimes they go into weird directions. This is still early days for open source vision models. We have llava and bakllava on the library today, and llava is also available as a 13b model, though it doesn't seem much better than the 7b model.
|
||||
|
||||
One of the interesting use cases I have seen for this is a automatic image renamer. So take the source name that is probably just an image count from the camera, figure out the keywords in the image, and rename the file to those keywords. Or maybe a better solution is to add the description to the EXIF metadata of the image for something like Lightroom to manage.
|
||||
|
||||
There are so many amazing ideas that are going to come out of this and when we start to see other models get released that take advantage of it, its going to be incredible.
|
||||
|
||||
I would love to see what you are building with vision. let us know in the discord, which you can find at discord.gg/ollama.
|
||||
|
||||
Thanks so much for watching, goodbye.
|
||||
71
scripts/llavagetsbetter.txt
Normal file
71
scripts/llavagetsbetter.txt
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
thumbnail - Shiny Llava with a volcanoe on screen
|
||||
|
||||
Shiny Llava! Yup we have a new model and a new version of Ollama to support it. Ollama 0.1.23 is out and along with it, Llava 1.6 has been released, offering 7, 13, and 34 billion parameter variants. I'll talk more about llava and give some examples in a bit. First let's look at some of the other features in 23.
|
||||
|
||||
Keep Alive. Wow, this has been a hot request for a long time. When Ollama starts with a model, that model stays in memory for 5 minutes. Let me tell you how many folks are happy with that.... exactly none. There are two strong opinions on this: One group says it should be longer and the other says it should be shorter. So now for API requests, you can pass a keep_alive parameter setting. This is a string. If you just pass 30, then its 30 seconds. But tacking on an s, m, or hr will clarify things a bit. This is just in the API for now. Maybe in the future, we will get this on the command line or as an environment variable or in the REPL.
|
||||
|
||||
Support for Nvidia GPUs has expanded a bit so some older cards are now supported. As long as your GPU has a compute capability of 5 or higher, you should be set. That ancient ultra cheap eBay special though may still only be good for scrap and not much more.
|
||||
|
||||
The ollama debug = 1 setting that I demo'd in a recent video is now in the product, so you don't have to build to get that. What that did was give the full details on prompts and outputs in the logs for ollama. Definitely not something you want running all the time, but when trying to figure out what an application is doing, it can be magic.
|
||||
|
||||
There were a few more smaller things, but lets start talking about multimodal. First you can add an image path when running ollama run. Just tack on the path to the end of the command. This isn't for working with the image interactively, but rather when you are also asking the question on the command line.
|
||||
|
||||
And now you can send a message to a multimodal model without sending the image, though I am not sure why.
|
||||
|
||||
Ok, so lets get into using llava 1.6. Llava stands for Large Language and Vision Assistant and its all about doing image to text. First off, how do you get it. Well just like any other model, do ollama pull llava, or whatever tag you are using. If there is a newer version available, it will download what is new. I have a tool, creatively called ollamamodelupdater that will go thru all your models, searching for ones that need an update and then it pulls the update. It's more than just running ollama pull on everything. My tool compares the manifest on ollama.ai with what you have and only initiates the download if there is something different. This often saves me 20-30 minutes to update everything. There will be a link to the tool below in the description.
|
||||
|
||||
After you download the model, you can still go back to the previous version. Go to the ollama.ai page for llava and then the tags page and you can see there are a bunch of models that are the version 1.5 models. If this page is a bit confusing to you, check out this video that describes what is going on here.
|
||||
|
||||
So while you are downloading the new model you might be curious about what is new. The model now supports a higher resolution. This may be a bit confusing. Llava supports high resolution images, but to do so, it has to split the image into smaller pieces and then recognize what's in each piece, then flatten the images and results. Now, because it supports the higher resolution, it doesn't have to split the file up as much as it did before.
|
||||
|
||||
There is better visual reasoning and ocr. It's not a full on OCR engine; there are lots of OCR tools that run on low powered machines that perform better. And its definitely not great at what is often called ICR for handwriting, but it's still amazing to see how much better this is getting and it won't be much longer before those OCR tools can't compete. It becomes more interesting when you combine OCR with understanding the meaning on the image. So here is an example from their announcement paper. It’s an image showing flight info and the prompt is: I need to pick up my wife. I live in San Jose. When should I leave? And the model spits out:
|
||||
|
||||
"Based on the info provided, the flight is scheduled to arrive at 11:51 at SFO. If you live in San Jose, you should consider the travel time which is 45-60 minutes depending on traffic.
|
||||
|
||||
To ensure you have enough time, you should leave San Jose no later than 11:00 to account for traffic and unexpected delays. However, it's a good idea to leave earlier "
|
||||
|
||||
That’s pretty cool. Combine this with function calling and then maybe you get the actual travel info that day and add the appointment to the calendar and then this gets really amazing.
|
||||
|
||||
Here is a cool demo from AI and Design on Twitter where he has the model roast himself. "fashionably bald and bearded"? I resemble that remark.
|
||||
|
||||
Here is another one I think is really awesome. It comes from Tremorcoder in the Ollama Discord. Are you signed up for the ollama discord? You can find it at discord.gg/ollama. He gives the model an image and then asks for recommendations for edits to improve the image. That's such a cool use case. Apparently Llava 1.6 is so much better than 1.5 was for this.
|
||||
|
||||
One of my favorites is this Poetroid Camera, a play on Polaroid, which having worked at a camera shop in the 80's and 90's on the island near Miami where I grew up, I remember well. It recognizes what's in front of the camera, then generates a poem based on it. I thought it might be fun to try to recreate the software part of this, so I built a simple example. Let's take a look at it.
|
||||
|
||||
Right up top I read in a style and an image path from the command line. Then I create a new ollama object. I read in the image file into a buffer and then base64 encode the image.
|
||||
|
||||
Now I call the ollama chat endpoint, passing the llava model a simple prompt and the image. The first attempt at this I had it write the poem itself. But Llava seems to suck at coming up with different styles of poems. So instead I just have llava describe the image. Then I passed the description to llama2 and had it make a poem in the style of someone. And it's pretty cool. Let's try one.
|
||||
|
||||
It’s a picture of a motion sensor from onvis and it does an ok job. Next is a blurry image of a stream deck which it interpreted as some DJ equipment. I'll skip that one. But the third try is a view of the sunset from our house. You can see Rainier over here and downtown Seattle. Gorgeous. And here is what it comes up with for Dr Seuss:
|
||||
|
||||
Oh my oh me! Oh what a sight to see!
|
||||
A sunset view so serene and bright, you'll see!
|
||||
In the background, a house stands tall and proud,
|
||||
Overlooking the water, reflecting the day's crowd.
|
||||
|
||||
Above the house, clouds drift by in the sky,
|
||||
Tinted with colors that make you sigh.
|
||||
From warm oranges to cooler blues, they play their part,
|
||||
In this sunset scene that captures your heart!
|
||||
|
||||
In the foreground, a railing can be seen,
|
||||
Suggesting we're up high, in this sweet dream.
|
||||
The shadows grow long and the sun descends,
|
||||
Early evening, oh what a wonderful friend!
|
||||
|
||||
No text to distract or confuse, just pure delight,
|
||||
In this image that fills us with such pure sight.
|
||||
So come and gaze upon this view with glee,
|
||||
A sunset scene so serene, it's plain to see!
|
||||
|
||||
Yeah, that’s fun. Now a Haiku of the same image:
|
||||
|
||||
Sun sinks low in sky
|
||||
Golden hues upon the sea
|
||||
Peaceful evening's grace
|
||||
|
||||
Pretty cool. So that’s a little of what you can do with llava and whats new in Ollama 0.1.23. Do you have any cool projects you have seen with llava? Or how about ideas for things you want to build with it? let me know in the comments below. Maybe I'll cover what you are up to in a future video.
|
||||
|
||||
Thanks so much for watching. Goodbye
|
||||
|
||||
|
||||
20
scripts/offlineai.txt
Normal file
20
scripts/offlineai.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
Why are you using that online AI system? Every answer you have is probably wrong. It doesn't always provide a better answer. It doesn't always run faster. You don't have to be a machine learning expert to run an AI system. You don't even need to be a developer. If you found this video, you probably have the right skillset to get it going. All you need is a desire to run AI offline and local, a computer, and a willingness to try something new. That's it.
|
||||
|
||||
Of course, there are also reasons you might want to continue using online tools. Maybe you are always connected, maybe you aren't concerned about privacy or security, maybe you only have a phone, maybe....well... that’s all the reasons i can think of.
|
||||
|
||||
So let's get you on your way to running AI offline.
|
||||
|
||||
This video will be using a Mac because that's just the easiest platform to use. Linux is almost as easy. And then on windows you just need to turn on WSL then its exactly like using Linux.
|
||||
|
||||
Your first step is to open your web browser and visit ollama.ai. This is the easiest tool out there by far, especially when it comes to installation. OK, click the big download button. If you are on Linux or on Windows with WSL, then choose the Linux tab and run the command shown. If running that curl command scares you, there is a link to the shell script so that you can verify it. On Mac, go to the macOS tab and click the Download button. When the file is downloaded, double click the file that is downloaded and then run the file in there. You have to verify a few things but pretty quickly you will be up and running.
|
||||
|
||||
For some reason, folks are scared of the terminal, but there is nothing to be scared of. So open the terminal and type `ollama run mistral`. Mistral is an AI model that you can run locally. But since you don't have it yet, it needs to download first. You don't have to go through any steps, its already downloading. That completes quickly, and soon you will be plopped into the UI to be able to ask a question.
|
||||
|
||||
Now you can start asking questions just like you would with ChatGPT or Claude or anything else. To quit, you can use a slash command... / bye. Or you can press the control key at the same time as the d key. Next time you want to ask a question, open a command prompt, and type the same command, ollama run mistral. You already have the model, so it will start in seconds and you can ask your question.
|
||||
|
||||
As you get more comfortable with this you can go back to the web page and find different models in our library. And soon we will make it easy to find models made by other folks as well. Depending on the questions you are asking, there may be a better model, but mistral is a pretty good model to get started with.
|
||||
|
||||
There are a few more details you may or may not care about. First, other than downloading the app and the mistral model, there is no network required. If you have an Apple Silicon mac, or a linux or windows box with a recent Nvidia GPU, we will take advantage of it without any extra steps. If you are a developer, there is a lot you can do with this and even that is pretty easy.
|
||||
|
||||
So I think you have to agree that this is the easiest tool out there to get up and running.. to run AI models locally. If you have any questions, leave them below. Thanks so much for watching. Goodbye.
|
||||
|
||||
24
scripts/ollama0.0.12.txt
Normal file
24
scripts/ollama0.0.12.txt
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
Hey there,
|
||||
|
||||
Its Matt Williams from Ollama. A few days ago we released version 0.0.12 and I wanted to show you whats new and interesting.
|
||||
|
||||
When i run ollama in this video, you will notice 2 different commands. First there is ollama. That’s the version that you can install from the website. Then i have oolama. That is a special version I have compiled to let me see the previous version, 0.0.11, purely for the purpose of making this video.
|
||||
|
||||
Also, I will refer to v0.0.12 as version 12 in this video, and 0.0.11 as version 11, just to keep things simpler as I speak.
|
||||
|
||||
So lets start with a new subcommand. when I run ollama 11, you can see I have all the commands you are used to. but ollama 12 introduces cp. This will make a copy of the model with a new name. because of the way the layers work with models in ollama, we aren't actually copying the big files that can be many many gigabytes, but rather copying the manifest that references them. This will give you a nice way to change the name of any model you may have created. And if you remove the old model, you are just deleting the manifest that describes it. When you remove the last model that references one of those big files, then we can remove them.
|
||||
|
||||
The next improvement I want to cover is support for running k-quant models. Many of these models start with the tokens represented by 16bit floating point numbers. This provides for a lot of precision, but at the cost of a lot of space to store the information. Quantization reduces the precision to 2 bit integers, 4 bit integers, 6 bit integers and other levels of precision to save the space, and are often still surprisingly useful. More recently k quant models were introduced that offer a more efficient method to reduce the precision, resulting in even smaller models while again staying effective in many cases. I don't have a model to show you for this, but we will be adding them soon. The important thing is that we have expanded our support for different types of models.
|
||||
|
||||
Next is some performance improvements from enabling Accelerate. Accelerate is an apple feature that "provides high performance energy efficient computation on the cpu by leveraging it's vector processing capability"
|
||||
|
||||
We can see this by running the llama2 model 11 and seeing that the CPU is having to work pretty hard to evaluate the prompt. The answer uses the GPU and is very efficient already. But when we switch over to 12 and run the same question, you will see that the prompt eval is much faster and used less cpu.
|
||||
|
||||
In the Discord, we saw a few folks who were trying to access the Ollama API from a website. If you have done anything like this in the past you may know about CORS and how much of a pain it is. But now you can access the API from websites on localhost.
|
||||
|
||||
And the last of the improvements is around create. when you make a modelfile the first inst is a FROM instruction. In ollama 11 if you tried to create this model from a model that is already in the registry, it would fail because you needed to pull the model first. Now, we will pull for you if the model hasn't already been pulled. This is a much better new user experience
|
||||
|
||||
Finally there were a bunch of bug fixes which are all great to see. And that’s whats new in version 0.0.12 of ollama. You can find out more at ollama.ai and we can't wait to hear how you are using the tool.
|
||||
|
||||
|
||||
|
||||
23
scripts/ollama0.0.13.txt
Normal file
23
scripts/ollama0.0.13.txt
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Hey there,
|
||||
|
||||
It's matt williams from Ollama. Last night I finally posted the video about 0.0.12 and today I get to post another one about 0.0.13. This one is even bigger than the last.
|
||||
|
||||
Just like last time I have two commands I am running, but now it’s the opposite way around. So Ollama is 0.0.12 and oolama is 0.0.13. And to make it easier to say in the video, I will call 0.0.12 ollama 12 and 0.0.13 I will refer to as ollama 13. Again that’s just to make the video easier to follow.
|
||||
|
||||
Ok, lets get into it.
|
||||
|
||||
Models now stay in memory between messages. This is huge. Before if you had a chat session with ollama, we spent some time loading the model into memory. With. every. single. prompt. <shrug>. Now in 13 we are keeping it loaded in memory until you end the session with ollama. So lets ask a few questions in 12. and now ask those same questions in 13. Yeah, that’s pretty sweet. Oh and did you notice the change in the verbose output? Lets look at one of those from 12 and here we are in 13. You can see a lot more detail not in the output.
|
||||
|
||||
Next, we expand our compatibility story. Up until 12, we only supported Macs with Apple Silicon. So that’s the M1 and M2 chips. Now we have expanded that to Intel Macs and we are distributing the executable as a Universal binary. so no need to choose which platform you are on. And Windows and Linux support will be coming soon.
|
||||
|
||||
When you are in a chat with ollama, you now have a set of slash commands for show. this will let you inspect the current model to find out how its configured. You can show the license, or the system prompt, or the template used for the model. Did you know about the slash commands? You can turn on verbose, to see stats for each prompt, and /help will show you all the commands that are available.
|
||||
|
||||
You can also now have multi line strings when you run ollama run. These start and end with 3 double quotes. This was something that was requested in the Discord. Did you know about the dIscord? you can find out about it when you click the discord link at the top of the ollama.ai website.
|
||||
|
||||
Up until this version, whenever there was a new version, we would put a dialog right in front of you announcing the new version. If you chose to not install it then, we would automatically install it the next time you ran the server. Now we will show a more subtle hint that an update is ready in the menubar. There isn't really a difference in how we do the update, just how we alert you. This should result in a much better overall user experience.
|
||||
|
||||
When we first put out Ollama and started watching the Discord, we saw a number of folks experiencing crashes with Macs with 8GB of memory. We have fixed most of those issues so that those users should have a better experience going forward
|
||||
|
||||
We also fixed some issues when you had multi line strings in a modelfile, such as with the system prompt. So that’s great to see.
|
||||
|
||||
And that is pretty much everything new in version 0.0.13 of ollama. I hope to see you all in the discord and I really do want to learn about how you are using Ollama. Until next time, goodbye.
|
||||
23
scripts/ollama0.1.18.txt
Normal file
23
scripts/ollama0.1.18.txt
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
And boom, there is another version of Ollama out for everyone to play with. Let's take a look at what is new in this one:
|
||||
|
||||
The repl is the main UI for most folks using ollama alone without any other addons. But sometimes movement around the prompt in the repl can be a bit frustrating. You can paste multiline text in there, but correcting something in that text isn't always easy. Patrick on the ollama team added a lot of control there, but it wasn't fully documented. And now it is. I'll show you what you can do here in a little bit.
|
||||
|
||||
There is apparently better performance when sending followup messages to ollama using the repl or the api. There were reports of ollama slowing down after a few back and forths, so I hope that is now resolved.
|
||||
|
||||
For folks with nvidia gpu's with 4gb of vram who tried to load a 7b model, you should have fewer errors. We shall see if those comments go away in the discord.
|
||||
|
||||
Support for Llava models came in late December. You could say something like "describe this image", then drag over that image onto the prompt, and the path would be pasted to the end of the prompt. Well now prompts can start with the file path. I'll show you that in a sec as well.
|
||||
|
||||
A few versions ago there was a release that would allow a model to stay in memory if you just changed the system prompt. I used this in my mentors example where I would ask different personalities a question. But if you changed certain options or parameters, it should reload, but it wasn't doing that. That is now fixed.
|
||||
|
||||
Ollama started out when GGML was the only format for llama.cpp. And then a few months back, the authors of that tool haphazardly changed the format to GGUF without a whole lot of notice. Ollama continued to support both GGML and GGUF. This means there are essentially two parts of llama.cpp in there to support both models. That will be going away soon, so any models you have that use ggml will now be automatically repulled and updated to gguf. If you have posted a model to ollama.ai that uses ggml, you should update them.
|
||||
|
||||
So now lets go take a look at a couple of those. Lets start the repl using `ollama run llama2`. now press forward slash, question mark. or forward slash and the word help. most of this has been here for a while. What is new is that last item: slash question mark shortcuts. You can see a few items here. Ctrl a and ctrl e move to the beginning and the end of the line. The next set of options don't work for me. Apparently alt b and alt f are supposed to go backward and forward by a single word. That would be really useful. ctrl k is supposed to delete the next sentence, but doesn’t do anything for me, and ctrl u is supposed to delete the sentence before where you are, but it deletes the whole prompt.
|
||||
|
||||
The next 3 all work perfectly for me. ctrl L will clear the screen, ctrl c with stop the model responding, and ctrl d will exit ollama, the same as typing /bye. This list of commands is something patrick started working on a while back and apparently its tough to get working right. I use a weird keyboard layout, but it doesn't work on qwerty either, for me at least. If it works for you let me know in the comments below.
|
||||
|
||||
The next thing I want to look at is the change with llava prompts. So we are still in ollama, but I want to launch the llava model. So /bye and then I will run `ollama run llava`. Now "Describe this image" and drag over an image from my machine. You see it pastes in the path to the image. press enter, and you get a description. But if you did it the other way, it didn't work. It gave a weird error. Now you can drag the image over, then ask your prompt. And that works. This only applies to the cli. using the api, you don't provide a path in the prompt. Instead you have to include both the prompt, and an array of base64 encoded images in an images field in your body. And then you can submit that. so there is nothing new here for the api, its just for the cli.
|
||||
|
||||
And that's all that's new with 0.1.18. In the announcement, it does list 4 models as being new, but you don't have to be on the latest version to use them, like you did when the llava models got released. I'll do some videos about those models soon.
|
||||
|
||||
If you find this video useful, let me know in the comments below. And if you want me to cover anything else, let me know what you want in the comments as well. Thanks so much for watching. goodbye.
|
||||
17
scripts/ollama0.1.19.txt
Normal file
17
scripts/ollama0.1.19.txt
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
The last video I put out was 2 days ago, and that was about version 0.1.18. And now we have 0.1.19. There are a bunch of fixes in this one, rather than any new features, but most of them are very important, especially if you are affected by them. The maintainers of Ollama have worked hard at supporting new platforms, like AMD cards as well as a native windows app and improvements to Mac, and gradually as more users are starting to work with it we saw more memory problems. There are a number of variations on "memory" issues, many of which are addressed here.
|
||||
|
||||
So there are a few issues cleared up around context size, as well as out of memory errors. There were also some problems with older nvidia gpus. Some improvements were made to lower the requirements for mixtral. Intel Macs got some performance improvements. One of the big ones for a lot of users of some of the community integrations is support for browser extension urls in OLLAMA_ORIGINS. And ollama will offload to GPUs more where possible. There is also a new cool model to take a look at.
|
||||
|
||||
One of biggest and weirdest issues, and maybe most ornery to figure out was around context size. There were new models supported that offered up to 32K or even bigger context sizes. Calculating the memory required for the models themselves is relatively easy. 7b, at least 8gb-ish. 13b, at least 16gb ish. But figuring out the memory for context has been harder. And so if you didn't have the memory needed, and Ollama didn't expect it, you could hit a rather severe crash, either just ollama, or sometimes, the whole system comes down. I saw my MacBook reboot a few times unexpectedly.
|
||||
|
||||
Most folks wanted to try the models but didn't really take advantage of the bigger context, which were enabled in the modelfiles using a larger value of the num_ctx parameter. So a few weeks ago, all the models were updated to use the default context size of 2k or 4k. If you wanted to use something bigger, you could force a larger context using the num_ctx option. Only problem was that that option didn't always work right. Well, now it does. Let's take a look at how to set the context size. First in the cli or repl. so ollama run mistral. This is one that accepts a 32k context size. `ollama run mistral`. According to the ollama.ai library, this model is version 0.2. So going to the source repo on Hugging Face I saw that the initial version of mistral had an 8k context, but v2 had a 32k context. So let's go ahead and use that now. Type /? and we see the ollama help screen. /? and set and we see all the things we can set here in the repl. I want to set a parameter. so /set parameter num_ctx 32768. and press enter. I don't have an example large context to use but this now actually works. Though you definitely are going to need some memory to handle this.
|
||||
|
||||
And now lets use the api to set the size. I am in vscode and I find the easiest way to test rest endpoints is to use the rest client from huachao mao. its at 4 million downloads so I am not alone.
|
||||
|
||||
so POST to the api generate endpoint. the next line is for headers, so skip a line and add your object. I'll set model to mistral, prompt to why is the sky blue. stream to false, just to make this easier. and then add an options object with num_ctx set to 32768. Send that request and we see that it processed.
|
||||
|
||||
The last example I'll do is if we want to create a new model that always has that set. So in a new directory, I'll create a Modelfile. FROM mistral. PARAMETER num_ctx 32768. And since that is all we are changing, that’s all we need. Now back at the command line i can run `ollama create bigmistral`. Normally i need to say `-f modelfile` but if we are in the same directory and its called Modelfile, we can skip that. and now `ollama run bigmistral` and we have our mistral with a big context.
|
||||
|
||||
It's hard to demonstrate the rest of the improvements but I definitely want to create a video that shows the benefit of a larger context as well as it's impact on memory usage. If that is something you are interested in, or you would like to see anything else, let me know in the comments below. I'd also love to hear about how some of these fixes affected you.
|
||||
|
||||
thanks so much for watching, goodbye.
|
||||
57
scripts/ollama0.1.26.txt
Normal file
57
scripts/ollama0.1.26.txt
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
I think we may have what could be the most significant release for Ollama in a long time, which you can find out more about at ollama.com. I am thinking it may one of the top 5 or so most significant new features. But when I watched the discord for what folks were excited about, I think they were looking at the wrong thing. They saw the top item, the headliner, which is about a new model, Gemma, from Google. But the exciting thing here is just one of the line items down below. The line is support for BERT and NOMIC-BERT embedding models. This is huge. And it’s a foundational feature that allows Ollama to be used in far more places than ever before. It’s the feature I begged the team to deliver on in August. And it's finally here.
|
||||
|
||||
Embedding is all about creating a vector that represents the semantic meaning of whatever data you provide the model. The most common use case for embedding is in RAG search. RAG lets you find relevant content to your question so you can provide the model with the right inputs to come up with a good answer. Even with larger contexts of today's latest models, RAG is still incredibly important to keep the model on point and to move with speed.
|
||||
|
||||
I just heard a podcast today talking about how RAG isn't very good because it only delivers a few hopefully relevant fragments of the source text. Sure, that’s the Hello World of RAG, but there are so many examples of rag that uses those fragments and larger sections plus summaries plus summaries of summaries to try to make what the database delivers more relevant. I even made a code sample in the Ollama repo that shows this using a portion of the collection of the Chicago Institute of Art, and that was back in September.
|
||||
|
||||
When you build out a vector database for RAG, you provide a lot of content that first needs to be 'embedded'. That embedding, along with the source text, is stored in the database. When you ask a question, that question is also converted to an embedding. Your question embedding is the same size as all the other embeddings for all your content. So it's actually very easy to mathematically compare the embeddings to find the ones closest, or most similar, to your question. And often a vector database can do that comparison with millions or more other embeddings in way less than a second.
|
||||
|
||||
As a side note, there are a bunch of different vector databases out there that you can use in your applications. I can't really say what's different about them. The main differentiators seem to be around how easy they are to use in python vs typescript, or maybe how easy they are to host outside of an application. Or how they serialize the information to disk. I'm not sure there is a big difference in how fast they can filter information, but there may be a difference in their maximum capacity. I think that would be a good thing for me to look at in a future video. Let me know if that would be interesting to you.
|
||||
|
||||
Ollama has supported embedding for a long time, but it only used the regular models like Llama 2 and Mistral and everything else on Ollama.com in the past. This will work, but it turns out to not be super accurate. And even worse, it's really slow. So whenever someone asked, I would usually recommend not using Ollama embeddings and instead use the HuggingFace API's that you can run locally to do that embed. But every time I did that, I had to read the same article to figure out how to set it up. It tended to be hard to do. And so most just went to the OpenAI embedding model instead.
|
||||
|
||||
So let's take a look at how to do this with Ollama now that we have version 0.1.26.
|
||||
|
||||
First, let's try running this on the command line. I am using curl with a simple phrase. And there is our embedding. Superfast. But hopefully, your documents are a bit more complicated than this.
|
||||
|
||||
Normally, you don't want to embed an entire document all at once. Instead, you need to split it up into chunks and then embed each of those. That way, you can supply just the relevant parts of the document to the model. This isn't just about context size. You also need to provide info that makes sense for the question. There are a lot of strategies about how large the chunks need to be and also how much overlap there should be between them. What do you summarize and should you also summarize topics that cross multiple sections along the way. But that's a topic for another video.
|
||||
|
||||
So here I have some code that splits a text file into 500 word chunks. This is using Bun which is an alternative to JavaScript. And then I am going to feed it the text of war and peace, which is about 550 thousand words, or about 1100 of our 500 word chunks. Then I will loop through each one and embed them using nomic-embed-text. So let's run it.
|
||||
|
||||
I skipped to the end and the process took about 50 seconds to run. Which is super impressive. looking at the logs for Ollama, it looks like each 500 word chunk took about 40 milliseconds to process. Let's compare that to what llama2 would take. I'll just swap out the models and run it. Each chunk takes about 1.4 seconds. So in the time nomic embed did ALL of war and peace, Llama2 did 35 chunks. All of War and Peace will take llama2 about 25 minutes. That's a pretty huge difference.
|
||||
|
||||
Let's take a look at the code in python to do the same thing, in case you are interested. And to run that takes, well, just about the same amount of time as the js version...50 seconds.
|
||||
|
||||
Most of the code in both examples is reading in the file and chunking up the text. The actual embed is basically a single line of code that takes 40 ish milliseconds to run.
|
||||
|
||||
I am super excited about what we will be able to do with embedding now that it runs reliably well in Ollama. And not just reliable, but superfast.
|
||||
|
||||
The other features in 0.1.26 include support for Gemma from Google, which I'll take a look at soon. It looks like the team is still working with Google to make the model more reliable on its responses. And there is some clean up for Windows support. So that's great. Regarding Windows, I saw a comment just now pointing to issues with the way I set up environment variables. The recommendation from the team is to use system variables, but it was suggested that that might not be the right solution. I'll take a look at that and see if I need to make a correction. That video was made when Ollama Windows existed for about a day, so wouldn't be surprised if I got something off.
|
||||
|
||||
Anytime anyone finds a problem with one of my videos, I am super happy to replace it with the corrected content. It has to be credible and repeatable, though, so don't just claim that bunnies can fly without some way for me to verify it. But if there really is a way they can fly, I would update the appropriate video right away. Though this may be the first time I mention bunnies in any video of mine. Maybe YOU know what I am actually talking about there.
|
||||
|
||||
Well, thanks so much for watching. I hope you are as excited about Ollama 0.1.26 as I am. let me know what you think in the comments below. I love the comments and they have been particularly active more recently. And as for cadence on videos, I am still figuring it out. I am going to experiment with the idea of making a video like this every Monday and Thursday and then lots of shorts based on the content every day. We'll see how that goes. My wife and daughter are feeling the impact of 3 a week. Again, thanks so much for being here. Goodbye.
|
||||
|
||||
---
|
||||
|
||||
# shorts
|
||||
|
||||
## 1 - Announcing 0.1.26
|
||||
|
||||
There is a new version of Ollama out. Its version 0.1.26. You can find out more at ollama.com. The new features include support for Gemma from Google, some updates to windows, some memory fixes, and some better AMD logic. But I think by far the biggest new update is the one few are talking about. Embedding. Ollama has supported embedding since the beginning but it used the llama2 models and everything else on ollama.com. It did not support models specifically for embedding. And now it does. This is HUGE. This means that a RAG solution can be done superfast and entirely with Ollama. Before I recommended folks use HuggingFace, but I found that complicated to use. How fast is it? I tried embedding a document with 550 thousand words. I split it up to 1100 500 word chunks. When I did this using the llama2 model, it took about 25 minutes to embed. But with the new 0.1.26 and nomic-embed-text model, its down to 50 seconds. I am super excited about what that is going to mean for solutions that need local embeddings to work with models, and it's all because there is a new version of Ollama out...
|
||||
|
||||
## 2 - How to do embeddings with javascript and ollama
|
||||
|
||||
Doing embeddings is really easy with JavaScript and typescript using Ollama. In this example I am using bun which is a super fast runner and full ecosystem for JavaScript. So I'll start with `bun init` to create a new project. Then run `bun add ollama` to install the Ollama JS library. Now in my code, add `import ollama from ollama` and then I'll initialize the Ollama class. Now all i have to do is call `ollama.embeddings` and pass it an object with model set to one of the embed models on ollama.com. I will use nomic-embed-text. Then set prompt to the text you want to embed. I'll go ahead and output the embedding so that we can see it. And here it is. It’s a simple JSON object with a single key value pair of embedding set to a long array of floats. And that is the embed vector. Wish I was using Python instead, watch out for another one of these where I cover that. Learn more about Ollama at ollama.com. So as I said, doing embeddings is really easy with JavaScript and typescript using Ollama.
|
||||
|
||||
## 3 - How to do embeddings with python and ollama
|
||||
|
||||
Doing embeddings is really easy with Python using Ollama. I'll start with `pip install ollama` to install the Ollama python library. Now in my code, add `import ollama`. Now all i have to do is call `ollama.embeddings` and pass two parameters, model and prompt. I'll set model to one of the embed models on ollama.com. I will use nomic-embed-text. Then set prompt to the text you want to embed. I'll go ahead and output the embedding so that we can see it. And here it is. It’s a simple JSON object with a single key value pair of embedding set to a long array of floats. And that is the embed vector. Wish I was using typescript or JavaScript instead, watch out for another one of these where I cover that. Learn more about Ollama at ollama.com. So as I said, doing embeddings is really easy with Python using Ollama.
|
||||
|
||||
## 4 - Why is RAG relevant with larger context models
|
||||
|
||||
RAG. It's the usual solution to getting all of your companies knowledge into a Large Language Model so that the model can answer your industry-specific questions. But now we are seeing more and more models with massive context sizes. To support that, they need massive amounts of RAM, and that doesn't come cheap. Plus, it takes a while to populate that massive amount of RAM with content, especially if it's not already on the machine running the model. And you don't have to be an honorary member of the tin foil hat crowd to think that a search engine company with access to all your companies secrets might not be a great idea. But even if you or your security team are ok with that, then having the model sift through maybe 80% of material that is irrelevant to the question can have a detrimental effect on the speed of the answer. Plus, some of the newly announced models aren't even available and some companies have a history of over promising and under delivering, plus yanking the product out of existence at random times. I think for all of those reasons, there will always be a place in your stack for RAG.
|
||||
## 5 - what is rag in ai?
|
||||
|
||||
RAG. Retrieval Augmented Generation. It's been a key way to add all of your knowledge from your own documents into a model that you can ask questions to. But your knowledge isn't really all going into the model. Instead, it goes into a database, usually a vector database. Vector databases take raw text, metadata about that text, and an embedding. Embeddings are a mathematical representation of the meaning of the text. When you look at them, they are a series, or array, of floating-point numbers. And all the embeddings in a database will have an identical length, regardless of the length of the source material. One of the benefits of these vector embeddings of equal length is that they become really easy to compare with each other, so you can find the closest matches and therefore the text that is most similar to your query. And one of the easiest ways to produce the embeddings is called Ollama which you can find at ollama.com. Once you have a good set of matches, you can provide the source text to an LLM model as context to help it answer your question. So now you know what your colleague is talking about when they bring up AI and RAG.
|
||||
|
||||
21
scripts/ollamaandlangchaininpython.txt
Normal file
21
scripts/ollamaandlangchaininpython.txt
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
Can you talk to your own documents to get answers out of them? That’s the goal for many tools out there, and the concept is called embeddings. Feed your notes, your collected pdfs, and anything else you have, to your LLM and ask it questions to generate new insights. Ollama is already the easiest way to work with LLMs on your laptop, but can we support embeddings? In this video, I'll show you how a Python developer can use embeddings on Ollama using LangChain.
|
||||
|
||||
So let's say you have a document that you want to ask a question about. I am going to use this Wikipedia article about the horrible fires on Maui just a few days ago. The URL is on the screen. So how do you get started?
|
||||
|
||||
Since we are using LangChain in this video, lets start with 'pip install langchain'. OK, now create a python file and start building. we first need to import Ollama. 'from langchain.llms import ollama'. Then we need to initiate our connection to a model on ollama. 'ollama = ollama base url = http :// localhost : 11434 and model = llama2'. we can specify any model here that either is on the ollama hub or that you have created locally. Now to test that that works, 'print ollama why is the sky blue'. Now if we run that, we will see why the sky is blue. perfect.
|
||||
|
||||
Now we can work on loading the document. When I did this the first time, i needed the python module bs4, so run 'pip install bs4'. Now we can add the import for the loader: 'from langchain.document loaders import webbaseloader'. then load the document. 'loader = webbaseloader and the url, then data = loader.load'.
|
||||
|
||||
Now when we ask it a question, chances are the whole document isn't needed to answer the question, but rather just the parts that talk about the concept I am interested in. But how do we limit what gets sent to the model. Databases are great for searching for a subset of content and spitting out the results, so lets use a simple vector database called chroma db. but any vector db doesn't really want the full document, it wants the document chunked up into smaller pieces. So we need to split it up first. LangChain has something for this called a text splitter, so let's add it.
|
||||
|
||||
'from langchain text splitter import recursivecharactertextsplitter' and now we can say how we want the text split up. 'text splitter = recursivecharactertextsplitter chunk size is 500 and overlap is 0'. so every chunk is going to be 500 characters and there is no overlap between the chunks. and then 'all splits = textsplitter.splitdocuments and feed it our data'
|
||||
|
||||
Now we can add those chunks to the database. But vector stores don't store just regular words, they store vectors. So the embeddings function is what converts the words. As of this recording, we don't have an embeddings function that langchain can use, so we will use the gpt4all embeddings. First install the python modules: 'pip install gpt4all and chromadb'
|
||||
|
||||
then in the file we add 'from langchain embeddings import gpt4all embeddings' and then import the database 'from langchain vectorstores import chroma'. Now instantiate that datastore. 'vectorstore = chroma.fromdocuments and documents = all splits and embedding is our gpt4allembeddings'.
|
||||
|
||||
In langchain, the central concept is the chain which connects a bunch of tasks together to complete a larger task. We can use the retrieval qa chain by adding to our file, 'from langchain.chains import retrievalqa' and then 'qa chain = retrievalqa from chain type and then ollama and retriever = vectorstore as retriever'. now we can ask our question to our document.
|
||||
|
||||
'question is when was Hawaii's request for a major disaster declaration approved'. so 'qa chain with a query of the question'. and that’s it. pretty quickly we get an answer. Sometimes the results of the query isn't spot on. I think one of the biggest factors in this is how we split up the source information. I think its better to have a bit of overlap. So if we set our overlap to 50, we often get better answers, but you may need to play with that.
|
||||
|
||||
and that’s how you can use ollama with langchain and python to ask a document a question. You could use a different loader to point to a directory, and you would probably want to keep the datastore up between questions so you don't have to keep importing. I'll share examples on how to do that later. And if you want to see how to do this with Javascript, keep an eye out for that video. Thanks so much for watching. goodbye.
|
||||
32
scripts/ollamaarchitecture.txt
Normal file
32
scripts/ollamaarchitecture.txt
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
How does ollama run? What are the pieces? What happens when you ask a question to the model?
|
||||
|
||||
I have seen these and variations of these questions on the Ollama Discord, on the comments for the videos on my channel, and even on my Twitter where I am technovangelist and on Github where I am also technovangelist.
|
||||
|
||||
So let's look at all of this in a bit more detail.
|
||||
|
||||
As of the recording of this video, Ollama is running on three platforms: Linux, Mac and Windows.
|
||||
|
||||
So for those three platforms, there is a single supported installation method for each. On Linux, there is an installation script that you can find on the site, and on Mac and Windows there is an installer. What do they do? Well, let's look at the script for Linux. There is a lot here that is just dealing with CUDA drivers. In fact, in the 266 line shell script, well over 150 lines are just dealing with Nvidia. The rest of the script copies the binary into the right spot. Then sets up a new user and group so that the service doesn't run as you. And then sets up the service using systemctl and ensures that it stays running. The Mac and Windows apps are a little different. But ends up with the same basic results. There is a binary that runs everything and there is a service running in the background using that same binary.
|
||||
|
||||
There is only a single binary, but it can run as a server or as the client, depending on the arguments given. To work with Ollama, there is always a server and there is always a client. That client can be the CLI or another application someone has written using the REST API. When you run `ollama run llama2` you are running the interactive CLI client. And the client doesn't actually do anything other than pass the request on to the server. Again, the server is running on your machine as well. We aren't talking about any service running up in the cloud (unless YOU have set up a server to do that). The server, running in the background, takes that request and loads the model and lets the client know that it's ready. Now you can interactively ask a question.
|
||||
|
||||
The same thing happens when you use the api to send a message to ollama. The ollama server loads the model and asks the question. Then it returns the answer to your api client. There is no need to run ollama run and the model if you are using the api. The cli client is just another api client just like the program you are writing.
|
||||
|
||||
Now I said all this runs locally. There are three exceptions to this. The first is when you have put the server on a remote machine. The other two are when you pull or push a model. In that case, a model is either being downloaded or uploaded to the ollama.com registry. So that opens up another question. Does ollama use my questions to improve the model and does that get uploaded to ollama.com when I push the model. That is of course one of the big concerns with using ChatGPT and other online models. Often your interactions with them go back into making the model better. Asking a question and getting an answer out of the local model with Ollama can take a while, but that amount of time is nothing compared to the time required to fine tune or train the model using your data. You would hear the fans whirring hard for a good long time if Ollama was able to do that. Ollama has no ability to fine tune a model today, so when you push a model, none of your questions and answers are added to the model...for the most part. I'll talk more about an exception there in a bit.
|
||||
|
||||
Now some folks hate that there is a service that runs models running in the background all the time. It's going to take memory, right? Models are big, and it shouldn't stay in memory, right?
|
||||
|
||||
The memory consumed by the service is whatever is needed by the model while it is running. Then Ollama will eject that model after 5 minutes, although that is configurable. At that point, it drops to a minimal memory footprint. There isn't really much reason to stop it at that point, but if you feel strongly that it shouldn't run, then here is how to do it.
|
||||
|
||||
On Mac, come up here to the menu bar, click the ollama icon, and then choose Quit Ollama. On Linux run systemctl stop Ollama at the command line. And on Windows, come down here to the tray icon and choose Quit Ollama. If you just go and kill processes, they will restart and you will get frustrated. If you are on a linux distro that isn't systemctl, then you either installed it manually or you used a community created install. There are a few of those, and I can't really suggest the right way there. To get it started again, run ollama on mac or windows, and on linux run `systemctl start ollama`.
|
||||
|
||||
Some folks hate the fact that ollama gets rid of the model after 5 minutes. They either want that time to be shorter or longer. You can set the time using the api parameter of keep_alive. If you set 'keep alive' to -1, Ollama will keep the model in memory forever, or you can specify the seconds, minutes, or hours. For now, as of this recording, this has to be done in the API and not via the cli or environment variables.
|
||||
|
||||
Remember a moment ago I said 'For the most part" with regards to adding your questions and answers to the model? There actually is an exception to this. But it's a pretty special case. If i do 'ollama run llama2' and then ask it a few questions. "why is the sky blue", "why is the wavelength longer or shorter", and "can i surf those waves".... It's an example, give me a break. Then I run `/save m/mattwaves` (where m is the name of my namespace on Ollama.com), I have saved those messages as part of the model. The messages aren't in the model weights file, though. I'll come back to that in a sec.
|
||||
|
||||
So lets take a look at how this works. First the manifest for this model. Here we can see there are a few layers, and this one is called messages. Lets open the blob file it mentions. See the questions? they are all there along with the answers. So these are just like the messages you would set if you used the chat api. For instance if I want to use a few shot prompt showing the model how I expect it to provide a json formatted object, I would add the messages here. This is available in the modelfile as well using the message instruction. And they appear here as this messages layer. So you might think based on this that you could just edit these messages here in this file and it would replicate that behavior we saw in the modelfile or in the api. That will continue to work locally, but as soon as the file was pushed, the file signatures would be different and it wouldn't work. So if you want to achieve this with the CLI, you will have to create the modelfile and update the messages there. Again, pretty special circumstances.
|
||||
|
||||
When we looked at the manifest, we focused on the messages layer, but there are a few other layers as well. You can see one for the system prompt, template, and others. One of them is the model weights file. That's the really big file for each model. See how the name of the file is the sha256 digest of the file. When Ollama get's the manifest, it looks to see if the corresponding files are on the system. If it already has the file, it doesn't download it. So you might have a model llama2 and then another model call mycoolmodel someone has created based on llama2 with a unique system prompt. When you pull that model, the model weights file will already be there so adding the new model will have minimal impact on space consumed on your drive. Similarly, removing llama2 at this point will have minimal impact on your drive because mycoolmodel is still using that model weights file.
|
||||
|
||||
I think that's all the info on how the pieces work together and how to use Ollama. If you have any questions about this or anything else, let me know in the comments below. Thanks so much for watching
|
||||
|
||||
32
scripts/ollamaindocker.txt
Normal file
32
scripts/ollamaindocker.txt
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
The main way most folks install and run Ollama is to start with the installer that you can find on ollama.com. You can be up and running super quickly with that. But some like to use Docker. Docker is nice because it is fully self-contained. For programs that are messy with a lot of dependencies, it can be nice to use Docker because when you delete the container and image, there is nothing left. Ollama is a very simple program with a single executable, but still its convenient for some to have everything running in Docker. You will take a little performance hit, though. On Linux, it's pretty minimal, but on Mac and Windows it will be a little more significant due to the virtual machine that needs to run underneath Docker. Also, on Mac, there is no GPU pass-through possible, due to the Docker platform not supporting it. Just on Mac.
|
||||
|
||||
Once you know you want to run Ollama in Docker, you still need to put your models in a directory on your base system. Typically, docker containers and images are designed to be really small. But the models you run with Ollama are enormous. So that's why they are separate. Though, with Docker, it may be touch easier to put your models anywhere you like.
|
||||
|
||||
I am going to assume that Docker is already set up on your machine and is ready to go. The command to run is `docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama`. Run it, and then we can take a look at the command in a bit more detail. `docker run` is the command to start a new container from an image. If you don't have the image, it will be pulled from Docker Hub. `-d` says to run the container as a daemon, so it's running in the background. `--gpus=all` allows for GPU pass-through. BUT, this doesn't work on a Mac. And on Linux and Windows, you need to make sure the nvidia toolkit is installed, assuming you have an nvidia card. I am running this on a brev.dev instance which already has that installed, but you can find the instructions to install it in the README on the DockerHub page for the Ollama image. I'll talk more about Brev in another video coming very soon.
|
||||
|
||||
The next part of the command is the volume mount. This is saying create a volume named ollama and mount it to /root/.ollama inside the container. This is a little confusing as there are different ways to use volume mounts. But basically, there are two sides of any command that has a colon. The left side is usually what's on the host system and the right side is what is in the container. If the left side is a word and not a path, then the Docker process will create a new directory where its default is. On this system that is /var/lib/docker/volumes and there you can see an ollama directory. But if you want the models to go somewhere else, you need to specify the fully qualified path before the colon. I am currently in /home/ubuntu and if I want models to go into the myollamamodels directory which I have already created, I would have to use -v /home/ubuntu/myollamamodels:/root/.ollama.
|
||||
|
||||
Next comes ports. Any time there is a port that you need to access inside the container and want to use it outside, you have to declare it. So we want port 11434 inside the container to be available outside the container as well. After that, we set up a name. If you don't include a name, one will be generated. So its usually best to assign one that you like. Finally we see the Docker image being used: ollama/ollama which corresponds to the url on Dockerhub which is https://hub.docker.com/r/ollama/ollama.
|
||||
|
||||
Let's say you actually want to call the container something else, or you want to move the container to a new location, or there is a new version and you need to update the ollama container. Well in all of those cases, if you just run the command again it will fail, because there is a running container already. So we need to stop it and remove it. Luckily we set a good name so this is pretty easy. Just run `docker stop ollama` and then `docker rm ollama`. Now if you need a new ollama image, you can run `docker pull ollama/ollama` to grab the latest. Then you can run that `docker run` command again with the correct parameters. One thing that confuses new users is that they want to update the software inside the container, instead of pulling a new image. Images and containers are designed to be immutable. You don't want to update the contents of the container. If there is updated software, you pull the new version of the image and start that up. Updating the software inside a container will probably make it break much more easily. Don't do it.
|
||||
|
||||
Of course you didn't run ollama just to run the server, you probably want to use the client to ask a question. But ollama probably isn't installed on your host system. To run the ollama client that is inside the container, we need to use the `docker exec` command. `docker exec -it ollama ollama run llama2`. So that's `docker exec` which will run a command inside a container. `-it` says to run it in an interactive terminal. If you just needed to run the command and exit, you could leave that off. The first `ollama` tells docker exec which container to use. If you hadn't specified a name when running the image, then you would have to specify a container id which is a unique string each time it's run. Everything after the container name is the command to run on the host. So `ollama run llama2`.
|
||||
|
||||
Now I have used the terms container and image a lot, and if you aren't familiar, you might think I am using them interchangeably. But they are different. All the things on DockerHub are called images. ollama/ollama is an image. It defines how ollama should run. A container is a lightweight method to run an image. You can think of the container as the instantiation of the image. And we can see this on our system. We stopped and removed the container just now, but the image still existed and we can quickly run it. If you run `docker images` you will see a list of all the images you have downloaded to run as containers. If you want to remove an image, then the command is `docker rmi ` and the image name but it will only delete if there are no containers currently using the image.
|
||||
|
||||
OK, back to ollama run. We were looking at `docker exec -it ollama ollama run llama2`. If you run that you will be dropped into the interactive repl to work with ollama. If you are going to be doing this a lot, then it probably makes sense to make an alias. On linux and mac, assuming you are using the bash or zsh shell, the command is `alias ollama="docker exec -it ollama ollama`. If using fish, then just replace that equals sign with a space. If you are a Windows user, you probably know the right command to create an alias like that.
|
||||
|
||||
Now you can run `ollama run llama2` just like you do on systems with ollama installed. If you want to use that alias after this terminal session is over, you will want to add the command to one of your rc files for your shell. That's going to be a file like .bashrc or .profile or .zshrc or config/fish/config.fish.
|
||||
|
||||
There is another command you need to know about. Sometimes you have to look at the logs to see what ollama is doing. So `docker logs ollama` is the command to run to see those.
|
||||
|
||||
ok, so now you are setup to use ollama in docker on a host. But let's say you have setup ollama on a host, like I have on brev, and you want to access it from a remote machine, something other than the host running docker. Well if the host is on the same network as your client machine, this is easy. You will have to stop and remove your docker container for ollama. Remember, that was `docker stop` and `docker rm`. Then run the same run command but add `OLLAMA_HOST=0.0.0.0:11434` before docker run on the same line. And then anything that connects to the host on that port will see your docker container version of ollama.
|
||||
|
||||
But what happens if that host isn't on your home network. Instead its somewhere else on the Internet. Well then things get a bit tougher. Somehow you need to give access to the host to your client. Some will solve this by opening ports, but that's an incredibly stupid thing to do without blocking access with some sort of authentication. Probably the easiest thing to do is to use tailscale, which is free for most non-companies. For you at home, this is brain dead easy. And if you are doing this for work, then your ops team probably has a solution they like or tailscale is so ridiculously cheap that you can probably expense it and they wont bat an eyelash over it.
|
||||
|
||||
Side note, I once bought some stuff for the office when I was at datadog. It was the only time finance reached out and they said I needed to describe what I bought. 'You really don't want to know' I said. But I had to put it in. new people , new system. Don't worry they said. OK, so I put in what I bought. About $200 worth of NERF guns and those little yellow balls for ammo. I thought, oh well, guess I'll eat that expense. No problem. expense paid. Unfortunately the cleaning staff thought the balls were trash and within a week or so, all the ammo was gone.
|
||||
|
||||
Anyway, that's what you need to know to understand how to work with Docker and Ollama. In most cases, you will want to run Ollama as a native install, but if you insist on using docker, now you are set. If you have any questions, let me know in the chat below. I love the questions that I see, especially when you give me suggestions for what to make a video about. So many of these videos, including this one, come from those suggestions. Keep them coming.
|
||||
|
||||
Thanks so much for being here, goodbye.
|
||||
|
||||
44
scripts/openaicompat.txt
Normal file
44
scripts/openaicompat.txt
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
OpenAI. Heard of them? They have this AI product that is kinda popular, maybe you heard of that...ChatGPT. Well they have an API for others to use to leverage OpenAI's products. It's not the best to use, but its there and its pretty popular.
|
||||
|
||||
If you have been using Ollama for any amount of time, you know there is an Ollama Discord, and if there is one question that is more frequently asked than any other....it would have to be...no question, not even close.... it's... why is there only one freaking channel on this server. But this isn't that video. If you look at the second most popular question of all time... again, its so obvious, you only have to be in the discord for 30 seconds, it's about... why is my gpu not being used. Again, wrong video for that question. But the third most popular question... is absolutely, unequivocally, where is OpenAI API compatibility.
|
||||
|
||||
People don't even know what it means and they want it. Well, as of the release of Ollama 0.1.24, its right there for you to use. Nothing special for you to turn on. Now there are some features that aren't available yet, but for most folks it will just work. So does that mean that folks who spent the time adding Ollama to their product just wasted the equivalent of a few Bluey's? No, but Bluey is pretty awesome, even if us American viewers don't get to watch the pregnant Dad episode.
|
||||
|
||||
What else is in this release? Not much, its really all about OpenAI. Not that I don't appreciate EASP's pointer to llm-ollama or MRAISER's cuda contribution. But... let's talk OpenAI.
|
||||
|
||||
So this has API in the name of the feature but lets start with the opposite point of view. The end user who is working with ChatGPT for their regular jobby job. I am on a Mac so I did a search for regular client tools that use OpenAI in some form or another and do not support Ollama. At first I was going to use Obsidian, but it seems that most of the tools either support Ollama now, or don't have a way to add a custom URL.
|
||||
|
||||
Why is adding a custom URL important for ChatGPT? Well if you are a company and the very real privacy and security issues with ChatGPT scare you, then you can host the service yourself on your Azure environment. And then you probably want your users to use that service so that your company secrets don't get discovered by a reporter like what happened to Samsung.
|
||||
|
||||
I found a cool tool called MindMac. This is a super slick tool and I think I may consider buying it. Now when I first tried it I could have sworn Ollama wasn't in the supported list, so I set up Ollama as if it were OpenAI. Then when I started writing this script, I saw Ollama was in the supported list. So less useful for me for this video.
|
||||
|
||||
Then I found ChatWizard on Github and got it installed. This works great with chatgpt but has no idea what ollama is. If you come into settings you can see a place to put in a URL. At first I put in http://localhost:11434/v1 as per the ollama release announcement. But this wouldn't work. Thankfully I can use the Ollama Debug environment variable to figure out what is going on. There, you see that? It says /v1/v1.
|
||||
|
||||
Go back into settings and remove the v1 from the url. Before i knew you could add a model, I just did an ollama cp nous-hermes2-mixtral gpt-3.5-turbo, tricking the system to think it really was on OpenAI and that works. But it turns out you can add a model in the...ummm, ice block view? Just enter a model name and then you can define a cost if you like. There is no checking that the model exists, so be careful here. Then the model just works in the chat. Pretty nice.
|
||||
|
||||
Now lets change gears and get a little bit more technical, a little closer to the developer persona. AutoGen Studio. This is a pretty cool app from the folks at Microsoft that brought us AutoGen. The idea of Autogen is to make it super easy to to build agents that will do things for you using the power of AI. This gets more powerful when you combine the agents to work together on your tasks.
|
||||
|
||||
AutoGen and AutoGen Studio work with the OpenAI API. Autogen is a purely developer product, while studio is a web gui that is a touch more friendly. It has been popular to use Ollama with these according to the posts in the discord, but to do so you have to use LiteLLM in the middle. And I think even set up a webserver. Well, you used to have to do that. Now you can just use Ollama directly. Once you get Autogen Studio installed and up and running...which is easier said and done because its Python, go to Build and then the Models tab and then click the green New Model button.
|
||||
|
||||
Enter a model name, I'll use dolphin mistral, and then the API key. Something has to go in here, but it doesn't really matter what. Then there is the baseURL. The default to go here is http://localhost:11434. And that's it. Try out the model. Hmm, it failed. Ok, let's add the v1 to the url. Try again. And there we go.
|
||||
|
||||
From here you can create skills which are specific activities you want your agent to do. This could be to search the Internet or search a database or parse a file or whatever. These skills are written in Python so there is almost no limit to what you can do. Then you create agents that have a system message, a model, and possibly some of the skills defined. Then finally a workflow that orchestrates the different agents to do some sort of complex task.
|
||||
|
||||
Let's just use one of the examples, the General Agent Workflow. And have it run through the Sine Wave example.
|
||||
|
||||
Now this takes a minute or two on my machine. But while its working we can verify its running by checking out the Ollama logs as well as the Autogen logs. And there are the messages going into the local model. This example is writing a python script. It's simple so any of the common models should handle it. But for more complex tasks, perhaps a larger more specific model is required. Or if your workflow is querying a database using a skill and then interpreting that to English or another language, maybe a super lean and fast model is the approach to take.
|
||||
|
||||
This is super cool, but there is probably a warning somewhere not to use this on your local machine. It's creating code and running it without your input. So it could do a lot on its own. Now I am not worried that this is SkyNet or bringing on the doom of AGI. But maybe it could wipe out your entire machine. That's probably why docker is recommended for the python environment. I might actually spin up a new machine on brev to secure it.
|
||||
|
||||
I think it would be great to be able to cover Autogen in more detail in the future. Let me know in the comments if that is interesting to you.
|
||||
|
||||
Finally let's look at going one level deeper. You are now a full on developer. So we need to open VSCode. And now... go to it. Ahh, we need some help. So let's look at OpenAI's developer site. I'll go to chat and here is a code sample ready for us to try. Back to VScode, and I want to use Deno for this one. So I'll do a quick Deno init which creates the main.ts and deno json files. And then I'll replace the existing code with the code sample from OpenAI. Deno has a different way of dealing with packages, so to use a regular npm package, just throw npm: at the beginning of the import.
|
||||
|
||||
Now we need to update the constructor. First an apikey. I'll just set this to ollama. Next is the baseurl. And that’s going to be localhost and the port, slash v1.
|
||||
|
||||
That should be all we need. So we can run it. When you use Deno you need to be intentional about the resources used. so 'deno run --allow-net main.ts' and there is our message from ollama. And we can watch the logs to ensure that it really is Ollama running this openAI call. To make it a little more pretty we can print just the message content.
|
||||
|
||||
So, we have seen the new OpenAI API compatibility in Ollama and we saw it from 3 different perspectives: a user, a power-user, and an dev. I think this is pretty cool. Using the Ollama API directly is going to be easier, more performant, and generally better, especially with the official js and python libraries, as well as the community created libraries for rust and ruby and r and swift. But if there is an existing tool that uses the openai api today and lets you set the baseurl, then this is going to be super powerful for you.
|
||||
|
||||
Let me know if there is anything else you would like to see on this channel. It seems that a lot of you have been subscribing to the channel and I love every one of those subs. It is so exciting to watch how many of you are interested in me creating more videos, so keep it up and thank you so much for that, and thanks so much for watching this one. goodbye.
|
||||
|
||||
32
scripts/proglanguages.txt
Normal file
32
scripts/proglanguages.txt
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
Recently on this channel there was a video about using an offline coding assistant in vscode. There are a number of them out there, but I have had the most luck with Continue and with llama coder. Llama coder works in the code file, completing what you are typing, where as Continue will give you a chat interface with your code as context.
|
||||
|
||||
One of the common questions about that video is basically, what languages can I use with these assistants? And to answer that, we should look at what they are doing. So you can break down the process into a few steps.
|
||||
|
||||
First, you, the developer start writing some code. Maybe you add a comment and want the assistant to write whatever you asked for. Or maybe you want it to fill in the blank in the middle of some code. The assistant copies the code on the page and maybe some other pages for context. It then formats that code in a way that a model will expect to see it.
|
||||
|
||||
So what is the format? Well, many of the models use their own format with their own keywords. Figuring out how to build these models takes a long time and often the keywords and format weren't published for other models when the researchers starting building the one you are using. The model developers aren't trying to make our life hell...I think... I hope.
|
||||
|
||||
So what defines the format? The researchers go through a process called training that formats the inputs in a special way, feeds that to the model, and if the model answers the right way, adjusts the parameters of the model to try to ensure that it answers that way every time. And then it repeats that with a huge number of inputs and outputs and hopefully at the end we have a smart model. That’s a super simple way to look at it. I'll cover training and what it means in another video. But the model expects all future input to look just like the training input so we have to stick with the special format.
|
||||
|
||||
For models that use the deepseek format, that looks like fim_begin and then your input. fim_hole which indicates where you want the answer to go. Then more input and finally fim_end. Those angle brackets and pipe characters that you see are important to the format, but hard to say so I skipped them. Having that fim_hole command is pretty cool. And filling in the middle is often referred to as Infilling.
|
||||
|
||||
So once it has formatted the prompt, it hands it off to the model. But tools like this often don't actually run the models. In the case of Llama coder, its uses Ollama to run the model. So you need to have Ollama installed to run it. Ollama has a special endpoint it listens on for requests, gets the specially formatted prompt, and then outputs the answer, one token at a time. A token is roughly a word or common part of a word. Serving this back a token at a time is referred to as streaming.
|
||||
|
||||
The assistant takes that stream and outputs the answer to the code window.
|
||||
|
||||
So let's use llama coder to see this in action. In settings for llama coder, we start with an ollama server endpoint. If you are running ollama on the same machine as vscode, this will be blank. Next is the model to use. You can see that as of this recording at the end of January 2024, there is stable code, code llama, and deepseek coder. These are all special models that focus on writing code. And they all have formats that allow for filling in the blanks in the middle of a code block. Next is temperature. This is often associated with 'creativity', though that’s not really a great term for it. Models work by guessing the first word then figuring out what is the most likely next word. Having a higher temperature means that the most likely next word is not always guaranteed, and you may have something very different. If you want to use a different model you can specify it in custom, along with the format to use. This is great if you have a fine tune based on deepseek, stable code, or code llama which will use the same format. The final two options limit how much can be written in one swoop.
|
||||
|
||||
So now you can start writing code or add a comment. when you press the space key and nothing else for a second, it will feed what you are working on to the model. And that grey text is what it suggests you might want to use. You can accept the full suggestion with tab, or just the next word of the suggestion with command and arrow. I assume that’s going to be control arrow on windows and linux.
|
||||
|
||||
But when we did that we didn't see any special format that the assistant sent to the model. Is that just a black box? Well, it used to be. Let me show you something that will probably come out in 0.1.23 or another future version. If I quit the Ollama server and then build ollama myself and run that with the ollama debug = 1 environment variable, then I get extra stuff in the logs. Now i will start ollama run in another window and ask my favorite prompt. I am pretty sure I was the first one to use this in this space and now its pretty common, though if you find someone doing it first, i will ignore it and keep thinking I am special. Why is the sky blue? and we see my answer. Now go back to the server logs and scroll up, and we can see the prompt in the logs, along with the full answer. This is great because you can see how the template was applied to the prompt.
|
||||
|
||||
Now let's try using vscode.
|
||||
|
||||
And if we look at the logs, we can see the fim begin, fim hole, and fim end, just as i described. There are a lot more entries here, because its running every time i press the space key and then pause for a moment. But the concept is the same.
|
||||
|
||||
So that’s how this stuff works. But i still didn't really tell you what languages are supported. The best way to figure that out is to go back to the ollama ai page for the model and then find the link to the huggingface repo for the model and read their docs. For deepseek coder, that points us to the github repo for the model. And that shows us a list of programming languages supported. It looks like its pretty much every language you can think off, plus a few I hadn't heard of. Idris? Isabelle? Bluespec? Augeas? So yeah, your language is probably there. Though here is a page full of languages not supported.
|
||||
|
||||
for stable code, the list of languages is actually on the ollama.ai model page, a shorter list of 18 languages. Codellama seems to be a much shorter list, but I could be certain on what the list actually is
|
||||
|
||||
All of the models reference various benchmarks that all prove that their model is the best, but if you have seen my videos before you know my opinion on the benchmarks. they all suck wind. To understand what is the best model for you you are going to have to try them all. Also try the different sizes of the models. But I tend to choose the smallest that gives a good answer. Having to wait for a model to generate an answers means I won't and will just keep typing. And I really don't want to peg my gpu constantly, especially when on battery, because my m1 all day battery will be closer to my intel mac book pro with 45 minute battery and I don't want to go back to that.
|
||||
|
||||
16
scripts/stablelmzephyr.txt
Normal file
16
scripts/stablelmzephyr.txt
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
hey there, it's matt, one of the maintainers of ollama and i want to show you one of the new models we added to the library. Its called stablelm dash zephyr. It’s a 3 billion parameter model that feels like a 7billion parameter model but a whole lot faster. let's check it out. First if you don't have ollama, you can get started at ollama.ai. Then after installing, run ollama run stablelm-zephyr. why is the sky blue. Boom, look at that thing go. That’s awesome. Now the output isn't always perfect...sometimes its weird.
|
||||
|
||||
lets take a look at the modelfile. In the repl i can type '/show modelfile'. And you can see there is no system prompt. We will take a look at how to change that a bit later.
|
||||
|
||||
Stable LM Zephyr is the new model from Stability AI, the folks behind Stable Diffusion. Its being released with a 'non commercial community license'. It has a 4k context size which is decent. But it isn't uncensored, so asking questions about making drugs or bombs won't work. And you can't even ask for a recipe for dangerously spicy mayo. Some folks may think the license and the censoring is a deal breaker, but depending on what you are looking for I think it can be the perfect model for a lot of people. Like for those really low end of machines with just 4 gigabytes of memory or just when you need a super fast response, its absolutely amazing.
|
||||
|
||||
So let's tweak the prompt a bit. If you just want to try a few things, you can make changes in the repl. slash set system - You are a helpful AI assistant. Always answer every question in Dutch. and enter. and now my question. Why do dogs always spin in circles before they poop? Now I think that looks OK, but then again my Dutch is horrible. And I don't think Rosetta ever covered that topic. I lived in Amsterdam for almost 10 years but my job involved close to 90% travel, so never really got a chance to learn, and my manager at OpenText didn't think it was an important thing to focus on. Oh well. Lets update that to be a bit more useful. slash set system - You are a helpful AI assistant. Always answer every question in the same language it was asked in. Now that same question gets a better response.
|
||||
|
||||
If you want to make that a bit more permanent, turn it into a modelfile. I can add From stablelm-zephyr. then system and three double quotes, and my system prompt and then three double quotes to close it out. The template and stop words are inherited from the parent model so i don't need to include them. I'll exit and run ollama create myzephyr. and then ollama run myzephr. ask my dog spinning question and boom.
|
||||
|
||||
I really like this model. It's going to be my default for a lot of things, especially when i need something that runs really fast.
|
||||
|
||||
I hope you found this interesting, and let me know if you would like to see something else.
|
||||
|
||||
thanks a lot for watching
|
||||
goodbye.
|
||||
41
scripts/starcoder.txt
Normal file
41
scripts/starcoder.txt
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
|
||||
I woke up with a little tickle in my throat, so this one sounds maybe a little gravelly at times and maybe my voice will break like I am 12 like it did a few times in preparation for this. So... There is a new version of Ollama out and its headliner is support for...no...but it was a mind blowing ride i 1987... no...but man when that came out when I was 14 in 84, wow and it seems to have held up well, ... there we go, starcoder 2. This is a new software development model by the BigCode Project. I have seen a lot of requests out there on the Ollama Discord asking for this model. It required updates from llamacpp in order for it to work and those changes were merged a few days ago.
|
||||
|
||||
Why are folks excited? I'm not exactly sure....I think the main thing going for it is that it is new and shiny. Everyone loves new and shiny. You look at The Bloke's discord and the requests for new models seems to be flooded by folks who just want to be first on the request. They tend to not actually care about what is new and interesting about the model. They just want to be first to point to the new and shiny. Maybe it's the same here.
|
||||
|
||||
So Starcoder v2 is out. Is it interesting? I guess so. I was probably the 3rd or 4th youtuber you have seen covering this model. And if you look at all the others reviewing the model, it turns out they don't actually say anything beyond reading snippets from the blog post and paper. And so you may come to the end of those videos thinking that the model seems to be incredible.
|
||||
|
||||
But I think the more interesting story is the team behind it and seeing them deliver a model that moves incrementally forward and may make room for some amazing things in the future. BigCode is led by HuggingFace and ServiceNow. Sure, HuggingFace makes a lot of sense there, but ServiceNow? That seems weird. I remember them being just another PagerDuty clone but I guess they have been successful and done some acquisitions. But anyway, let's move on...
|
||||
|
||||
When starcoder 1 came out it was a pretty big deal. It may have been the first of the models to really focus in on coding. Unfortunately it was in a format that wasn't supported by llamacpp and thus not supported by Ollama. But when it came out, llamacpp was still a young project if it even existed, and the Ollama team was focused on making an amazing tool for ssh key pairs at keypair.com. It was a few months into the Ollama project that support for starcoder came along and by that time there were plenty of other coding models on the platform. So what was amazing before, was kinda ho hum by the time it got onto Ollama.
|
||||
|
||||
Starcoder2 looks like a nice update to the original, and days after its release, it's on Ollama, though as of the recording of this video its still a prerelease of the software. Hopefully by the time you see this, it will be a full release.
|
||||
|
||||
So what's different? Well a lot has changed in the world of LLM's in the year since v1. The training set has grown a lot. It's trained on a dataset called 'The Stack V2' which is 4 trillion tokens of coding projects. That's up from the 1 trillion tokens in v1. And whereas v1 of The Stack pulled from 80 or so languages, v2 uses over 600 programming languages. I got a few questions on a recent video asking if a few super niche esoteric languages were supported by some other model. Of course they weren't, but there is a good chance that that minecraft specific language you love is supported by this model. If you wanted to download the full dataset, prepare to delete everything else on your system, because it comes in at 67.5 terrabytes. The context window has also increased from 8k tokens to 16k tokens which is great. There is also the introduction of sliding window attention. This doesn't really decrease the 'memory' size but allows for the massive reduction in number of dot products it needs to generate for each token. so there is a minimal reduction in capability but with a massive reduction in compute needed to calculate the next token, ideally making it feel faster. I believe this sliding window is something that was introduced in the Mistral model.
|
||||
|
||||
Now there are a bunch of models that support these larger context sizes, but when you load up the default model in Ollama, it will allow for a context size of 2k. Originally the models were set to the full context size, but folks were trying out 7b models on laptops with 8 gigabytes of ram and irate when they got out of memory errors. The context size blows the requirements up a lot. If you want the model to have the full context size, create a new Modelfile with a FROM instruction pointing at the model name and a PARAMETER instruction of num_ctx set to 16,384. Then run `ollama create fullstarcoder` in that directory and you are set.
|
||||
|
||||
StarCoder 2 is focused on the "fill in the middle" use case. The idea there is that you provide code before and after what you want the model to generate. This is quite a bit different from providing a question that you want the model to answer, which is the case for instruct or chat models. So if you open starcoder in most gui's and ask a question, you will most likely get garbage.
|
||||
|
||||
So to use StarCoder 2 for a fill in the middle, you need to use a few special tokens to indicate the beginning and end, and where in the middle you want new stuff to go. We can go to the Hugging Face repo for one of the StarCoder2 models and take a look in the tokenizer config file to see the actual values. They are fim prefix, fim suffix, and fim middle. So you would have your code block and at the beginning add fim underscore prefix with angle brackets at the beginning of all that. And then fim underscore suffix with angle brackets at the end. Then whatever you want to be filled in would be indicated by the fim_middle with angle brackets. Here I have taken some of my bad code from my mentors example, and deleted some stuff from the middle and replaced it with the fim_middle token.
|
||||
|
||||
Normally you aren't going to put these tokens in yourself, but rely on some other tool to fill them in for you. Twinny is a great option for this in vscode and it supports fill in the middle and it looks like it already has support for the starcoder format.
|
||||
|
||||
So is starcoder v2 any good? Well, I'm not entirely sure. And no matter what I say, you should ignore me and judge it for yourself. Now I am sure someone is going to get to this point and scream at their monitor that the benchmarks prove that this is better than x or y or z. Sure, if you believe benchmarks, then this seems good. We can look at a cool chart and it seems convincing, but if it does, you should check out this book called how to lie with statistics by darrell huff. I have had this for 15 years but it was published in the 1950's and is just as great today. Often with the benchmarks you find models that perform really well according to the benchmark but then are terrible in actual practice. And every model shows the other models they perform better than and mysteriously leave out all the others. And there are all sorts of other reasons to not take the benchmarks as the Gospel. That said, they are a great indicator to show that perhaps things are getting better, but they should never be used to say that one model is categorically better than any other all the time. And then there is the whole need for benchmarks to be open source but let's not go there.
|
||||
|
||||
If you made it this far, you are waiting for one of two things. Either you are waiting for my 20 seconds of silence at the end of all my videos, or you are wondering when I am going to cover the rest of the new things in version 0.1.28 of Ollama. Apparently there is better support for llava 1.6. Those are the vision models that let you process an image into a text description. In some initial testing it seems to do a better job of working with multiple images which could be really interesting.
|
||||
|
||||
There is one user who demonstrated if they changed models super quickly over and over again 20 times in a row, Ollama would hang. So for that one person, its fixed.
|
||||
|
||||
Apparently there is another person who tried to install ollama on a Windows box with less than 4gb of disk. That now works, though it doesn't take many models plus the OS to rip through that number.
|
||||
|
||||
A more common issue was that on Apple Silicon, folks would run out of memory, even if the model should fit. Ollama is doing a better job there.
|
||||
|
||||
In my last video about docker and Ollama someone asked for the commands for Podman. I used to cohost a podcast with a guy named Bret Fisher called Devops and Docker Talk. We had the core devs for podman on the show and they tried to convince us that Podman was better than Docker in some way, but I'm still using Docker. Anyway, Podman was having problems detecting Nvidia GPUs and now that should be fixed. Another side note, if you miss my appearance on Devops and Docker Talk, I will be on another episode very very soon.
|
||||
|
||||
And now that embeddings in Ollama is actually useful, one specific scenario with an empty prompt won't hang the embedding endpoint. And that's what is new in Ollama 0.1.28 as of the recording of this video, and whats special about StarCoder 2. Whenever there is a new pre release, things get added and taken away as the release gets close, so don't be surprised if the final feature list is a touch different.
|
||||
|
||||
What do you think? Do you like StarCoder? Do you prefer a different Coding Model?
|
||||
|
||||
Let me know in the comments below and if you have any ideas for future videos let me know about those too. Thanks so much for being here. goodbye.
|
||||
13
scripts/usingollamamodelsinothertools.txt
Normal file
13
scripts/usingollamamodelsinothertools.txt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
One of the great things about Ollama is that it makes it super easy to download models that work with Ollama. You just run `ollama pull llama2` or `ollama run llama2` and if you don't have the model, it starts downloading. But lets say you also want to use the model in lmstudio. Well, now you go to `.ollama/models/blobs` and good luck figuring out which one is llama2.
|
||||
|
||||
So I created a simple shell script that creates symlinks to a folder of your choosing. You can find the script in the github repo, matts shell scripts and its called syncmodels. This was written for macos, so you might need to adjust it a bit for linux and windows.
|
||||
|
||||
let's go over the script here.
|
||||
|
||||
The first thing you are going to have to do is set the base directories. First there is the ollama directory. On mac, that’s .ollama/models off the users root. the manifest directory and blob directory are probably going to be the same for everyone. Public models directory is where ever you want the symlinks to be. Do not set this to anything with files in it, because my first step is to delete everything.
|
||||
|
||||
Next, go to that destination directory and delete everything in it, so again, don't point this to a populated directory.
|
||||
|
||||
Then we are going to iterate through the manifest directory searching for models. I set the user, model, tag, and digest for each model and tag. Notice that I use jq to parse the manifest file. This is a json file and jq is a super cool way to parse json on the command line. Then for each tag file, create the symlink and print out the model to the cli. And that’s it. Now you can go over to a tool like lmstudio and it finds all the models you have already downloaded from ollama inside of lmstudio.
|
||||
|
||||
let me know if this is useful for you. I wrote it a few months back and then have mentioned it every few weeks in the discord. So maybe next time you can just find it here on YouTube.
|
||||
21
scripts/usingthemodelfile.txt
Normal file
21
scripts/usingthemodelfile.txt
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
hey there. We are excited to show you the new modelfile to use with ollama. It's a simple file that encapsulates everything about using a model, including the model weights, the prompt, and all the parameters. It's now super easy to build something that works for a specific use case, then share that modelfile with your colleagues and they can have the same setup right away. Soon you will also be able to share specific trainings and maybe even the state of your model quickly and easily.
|
||||
|
||||
We are working on a registry and should have something that you can push your modelfiles to soon. And then it becomes a very similar experience to what you have today with Docker.
|
||||
|
||||
In docker you work with layers that stack on top of each other to create your complete environment. And we have the same thing with ollama. There is a layer for the model weights. Another for the parameters, and another for the prompt. When you share a modelfile and run it, if you use the same model, only the layers with the different parameters or prompts get downloaded. Soon we will support additional layers for training and maybe other functionality. When you look at the api calls that go back and forth when you grab a modelfile, you will see it looks a lot like docker.
|
||||
|
||||
When we started building ollama, we knew one of the biggest challenges with getting up and running with LLMs on your laptop is distribution. Finding a model that works with your setup is the first challenge. Do you go to Hugging Face? What files do you look for? Then tweaking the parameters is next. What is temperature all about? TopP? TopK? what are those? And there are so many others. And then of course there is the prompt. Often you can stick with the defaults, but sometimes tweaking the prompt is really helpful. You can tell the model what you are going to provide and what you expect the output to look like. But sharing those prompts is one challenge and then knowing where to put them in the UI is another. We knew we could make it easier.
|
||||
|
||||
So lets take a look at how to use modelfiles. First, lets just run a model. Its just like it was before. Ollama run llama2. This will download the llama2 model from Meta. And then you can run prompts against it. why is the sky blue? and there is our answer.
|
||||
|
||||
But lets say you want to customize things a bit. We will start just by defining a new modelfile and using a From Instruction. From llama2. Just like docker, we also support tags that you can add on with a colon and then the tag. Like latest, or maybe be llama2 you can add the 13b tag. I'll save that to a file called videoexample. You can call the file anything you like. And then use the ollama create command. Ollama create myl2 -f and the path to the modelfile. In this case myl2 is just what I want to call it. The name can be anything you like. Now i can use the run command. Ollama run myl2. And I am dropped into a prompt. so i can ask my favorite question. Why is the sky blue
|
||||
|
||||
Maybe we want to customize the prompt a bit. Sometimes i have to cook and I don't want to go to the store. I have some ingredients in the fridge, so what can I do with that? I want to give the model a list of ingredients and have it spit out a recipe. Here is a simple prompt for that. Notice this part shows what I want to use to start the conversation, and not to include in every question. and so now i will give it salmon, orange, whisky, and radish. And here comes the recipe.
|
||||
|
||||
What if we want to tweak the parameters. There is a doc in the repo that I added yesterday that covers the parameters available in the modelfile. I'll add temperature, top p, and top k. We also have license in case you need to distribute a license with your model. does it react differently to my ingredients with those parameters? Sometimes you will have to tweak it more or less depending on the model and your goals for the prompt. But it's really easy to do here. We will also be updating the menubar soon to make all of this possible without touching this CLI. But we wanted to focus on the most important stuff first. You know, the fundamentals.
|
||||
|
||||
There is a lot more we plan to add. We already have a few examples in the github repo. I am loving this one to generate midjourney prompts using a prompt I found online. I just fed it "new llama runner" and it generated a great prompt to give to midjourney, and I ended up with this speeding llama that I used in the thumbnail for this video. Here are the results of using the term "platform engineering" which is a popular buzzword today in the world of devops. How do you make an image about platform engineering. Nothing I would create myself would look anywhere near as cool as these. When I used to own the blog at Datadog for a short while, I was terrible at coming up with images, but if I had this back then, we may be in a different place.
|
||||
|
||||
Well, we are sure you will come up with other great ideas. I mentioned that soon we will open up the registry for sharing your models, but we can also add any other examples you come up with to our repo.
|
||||
|
||||
So that’s it for a quick intro to the modelfile. check it out and the rest of ollama and let us know what you think. Bye.
|
||||
24
scripts/usingtwinny.txt
Normal file
24
scripts/usingtwinny.txt
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
*What* is the best local vscode CoPilot replacement you can use? There are a lot of options out there. Continue is a big one, but it's only in a chat interface and not completion in the code window. There is Llama Coder which is code completion, but sometimes its actually nice to also have that chat interface as well. Some would say there is Cody from Sourcegraph but the pricing model is still a bit up in the air for local models. And there are a few others I have yet to try. Recently I did a pair of videos showing how I use Continue and Llama Coder together to make a perfect setup. And then Richard Macarthy reached out to tell me of a project he made called Twinny. He's from a region called Gower in Wales, which is gorgeous. But maybe I love the area so much because once when I was 10 years old I found a 5 pound note in the water on a beach on that peninsula. But I think it may also actually be a beautiful place.
|
||||
|
||||
I have no idea what Twinny means, but I think so far it may be the best of the coding assistants in vscode. There is still some cleanup that needs to happen, but its getting there. It has all the features of Llama Coder and Continue combined, but it also goes a bit further to make it easier to use. So here I am in a little program I was writing to make it easy to search on Ollama.ai for models from the cli. If I want to search for all the models on the server that use mistral I can search for that. Or everything with mistral dolphin or dolphin mistral then I can do this. Pretty useful.
|
||||
|
||||
Now as I was building this, Llama Coder was giving me good suggestions, but sometimes I needed a bit more. So with Continue, I can select this code to cycle thru all the repos and look for search terms. And i get an overlay that says use command m to select or command shift L to edit. Command M will select and copy to a new Continue chat window and command shift L will bring up a command box for you to type a request in and it will put the results back in the code window. But I find I have to clean up a lot when that happens, and the chat window doesn't always work. So there is a little friction there I hope they can resolve. I can also select some code, right click and choose a bunch of options, but this will also replace my code and again I have to do a bit of clean up with what comes out.
|
||||
|
||||
So let's try this in Twinny. After enabling, I'll restart vscode just to make sure everything is set. Sometimes when disabling and enabling some competing plugins I find a restart really helps. We'll start off in the settings for the extension. Things are a little rough here. There is an API URL which is really just the hostname. Then the API path to the generate endpoint. Then there are the ports for chat and Fill in the Middle. Next we have the model names. If you change the model for infilling, then you should also set the template format. We can disable autosuggest which is interesting. You can set a context length which I changed from 10 lines before and after to 30. And then a wait to delay generating completions. You can set temperature. Its pretty cool that it will try to bring in the context of nearby documents. And then a completion cache is neat. You can specify max token limits and then a few other things that I don't think anyone needs.
|
||||
|
||||
When I first made this video there was one big omission and that was the ability to set the Infilling template, so you had to stick with codellama. I reached out to Richard about that and as soon as he woke up he added a feature to adjust the templates for chat and the different functions, but not infilling. And then later in the day he added support for stable code for infilling. Deepseek coder still isn't there but I wouldn't be surprised if by the time you watch this, that is there. I still would love to the ability to use the next model that uses some other format that we don't know yet, by defining the format ourselves, but this is a good next step.
|
||||
|
||||
Ok with that out of the way, lets start working with Twinny. Of course it has the tab completion that Llama Coder has, but it’s a bit slower because I have to work with CodeLlama which starts at 7 billion parameters. But whats really special is if I select this code and then right click, I have a bunch of choices at the bottom of the menu. And this is what I really love. It makes it so easy to add types, explain, generate docs, refactor, or write tests.
|
||||
|
||||
Continue also offers that, though the way they list it is a bit more confusing. But most of those options in Twinny are here in the sidebar as well. They surface as buttons. So after explaining, I can easily refactor, or write tests. I can do that in Continue, but its up to me to type out what I want rather than clicking a simple button. Sorry, sometimes I am just lazy. And everything always gets a preview in Twinny which you don't always get in Continue.
|
||||
|
||||
I think this gets all the good things from both Llama Coder and Continue and may be the most perfect AI Assistant for VSCode so far. I just don't like the model chosen and that I can't use a model like Deepseek Coder.
|
||||
|
||||
Now some will say that deepseek-coder at 1.3 billion parameters or stable-code at 3 billion is nowhere near as good as codellama at 7 billion parameters. But to that my response is that it’s an apples to oranges comparison. There is a deepseek coder with 6.7 billion parameters. But, what I want in code completion isn't a full solution to everything in my head. Instead I want help completing the line or function I am typing. And I need it quick. As long as the results are decent, then speed is the most important factor. And I don't feel that I am actually giving up much in terms of quality. I think some of the most exciting developments in the next 6 to 12 months in this area is the improvement of the small models. The models that let you do amazing things without breaking a sweat on your laptop, or even run on a tiny device like a Raspberry Pi. Check out this video by Ian Wooten on doing that... AFTER finishing this one.
|
||||
|
||||
What are your thoughts on this? Is there another solution I should try? Privy is another one I have heard of but haven't had a chance to get into yet. CodeGPT used to be a favorite but its been a while since using it. And what do you think of that ollama.ai model search tool? Would that be interesting to share? Let me know in the comments below. If you have paid attention to the comments in every other video I have, you know I spend a lot of time down there. And every idea folks have is in my list of ideas for future videos and I do expect to get to them all. This one was from a response on Twitter 2 days ago, and that last video was a response to a comment from 2 days before that. So your comments turn into videos pretty quick... I would also love to hear about the best thing you have found at the beach where ever you are.
|
||||
|
||||
I think I can stick with this cadence of a new video every Monday, Wednesday, and Friday for a long while to come, so like and subscribe to see them all as they come out.
|
||||
|
||||
Thanks so much for watching this. Goodbye.
|
||||
|
||||
22
scripts/windowsatlast.txt
Normal file
22
scripts/windowsatlast.txt
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
Let me show you something. See this? its ollama. Let me zoom out. Yeah, its on Windows. Not with WSL. Windows. Native.
|
||||
|
||||
At long last it's finally here.
|
||||
|
||||
I want to give you a quick taste of how to install it and what you can do when its running. First you have to get the installer. Depending on when you see this, you may have to go to the Githb Repo and then find it in releases, or you may be able to find it on the ollama.ai website.
|
||||
|
||||
Once you have it, make sure you ha e your nvidia drivers installed. AMD may be available soon as well. With that ready to go, run the Ollama Installer. This is easy and you should see it complete soon. Once its ready, you can find the Ollama tray icon that lets you quit Ollama or navigate to the logs folder.
|
||||
|
||||
Now you can do the same thing you have been able to do on Mac and Linux for ages. Open a terminal or command prompt and run `ollama run mistral`. `/set verbose` and then `why is the sky blue`. And boom, there we are. Let's try mixtral. It's taking a while to download and this may be fixed in future releases or maybe even the final. I've noticed it takes a while to get started. but once it starts going it seems to work just fine. Now, ollama run mixtral, and I can ask a question. "What is a black hole? explain it like I am 5". And there it goes. This machine is running on a Tesla T4 card, mostly because that's the only GPU I could get running on my GCP account. I have a solution for that coming in another video very soon. And its super cool.
|
||||
|
||||
So it looks very familiar and works just like it does on Mac and on Linux.
|
||||
|
||||
Let's take a quick look at the .ollama folder. We can see its just like it is on the other platforms. I have a models folder and in there a manifests folder with manifests for all the models. You can see that the manifest is the same as the one on linux with a colon in the name for the blob. I don't think that is valid for a filename on Windows, so if we look at the blobs directory, we see that ollama is using a dash there instead.
|
||||
|
||||
When we look at the logs, we can see the full logs for Ollama. It looks like OLLAMA DEBUG is enabled, but maybe that will be turned off for the full release.
|
||||
|
||||
Performance for Windows looks to be comparable to Linux. On my OBM site, at obm.tvl.st, you can see that this Windows machine is very similar to a T4 machine running Linux.
|
||||
|
||||
And that's Ollama running natively on Windows. What do you think? I look forward to seeing the various Windows front ends pop up for this. Do you already have a favorite? let me know in the comments down below. And ask any other questions you have as well and I will try to answer them. Or ask in the discord at discord.gg/ollama.
|
||||
|
||||
Thanks so much for watching, goodbye.
|
||||
|
||||
175
sharedtools/bunjs/.gitignore
vendored
Normal file
175
sharedtools/bunjs/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
||||
|
||||
# Logs
|
||||
|
||||
logs
|
||||
_.log
|
||||
npm-debug.log_
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Caches
|
||||
|
||||
.cache
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
|
||||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
||||
|
||||
# Runtime data
|
||||
|
||||
pids
|
||||
_.pid
|
||||
_.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
|
||||
.temp
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
# IntelliJ based IDEs
|
||||
.idea
|
||||
|
||||
# Finder (MacOS) folder config
|
||||
.DS_Store
|
||||
15
sharedtools/bunjs/README.md
Normal file
15
sharedtools/bunjs/README.md
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# vp-sharedtools
|
||||
|
||||
To install dependencies:
|
||||
|
||||
```bash
|
||||
bun install
|
||||
```
|
||||
|
||||
To run:
|
||||
|
||||
```bash
|
||||
bun run index.ts
|
||||
```
|
||||
|
||||
This project was created using `bun init` in bun v1.0.31. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
||||
BIN
sharedtools/bunjs/bun.lockb
Executable file
BIN
sharedtools/bunjs/bun.lockb
Executable file
Binary file not shown.
34
sharedtools/bunjs/index.ts
Normal file
34
sharedtools/bunjs/index.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { Glob } from "bun";
|
||||
import sentencize from "@stdlib/nlp-sentencize";
|
||||
export async function getFileNames(path: string, namePattern: string, sortFunction: (a: string, b: string) => number = (a, b) => a.localeCompare(b)): Promise<string[]> {
|
||||
const files: string[] = []
|
||||
const glob = new Glob(namePattern);
|
||||
|
||||
for await (const f of glob.scan(path)) {
|
||||
files.push(f)
|
||||
}
|
||||
|
||||
return files.sort(sortFunction);
|
||||
}
|
||||
|
||||
export function embeddingFileSort(a: string, b: string): number {
|
||||
const [la, oa] = extractAndParseEmbeddingFileNames(a);
|
||||
const [lb, ob] = extractAndParseEmbeddingFileNames(b);
|
||||
|
||||
if (la !== lb) {
|
||||
return la - lb;
|
||||
}
|
||||
return oa - ob;
|
||||
}
|
||||
|
||||
export function extractAndParseEmbeddingFileNames(file: string): [number, number] {
|
||||
const matches = file.match(/l(\d+)-o(\d+)/);
|
||||
if (!matches) {
|
||||
throw new Error('Filename format is incorrect');
|
||||
}
|
||||
return [parseInt(matches[1], 10), parseInt(matches[2], 10)];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
14
sharedtools/bunjs/package.json
Normal file
14
sharedtools/bunjs/package.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "vp-sharedtools",
|
||||
"module": "index.ts",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@stdlib/nlp-sentencize": "^0.2.1"
|
||||
}
|
||||
}
|
||||
27
sharedtools/bunjs/tsconfig.json
Normal file
27
sharedtools/bunjs/tsconfig.json
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable latest features
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
|
||||
// Bundler mode
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
|
||||
// Best practices
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noPropertyAccessFromIndexSignature": false
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue