--- title: Ollama app_file: main.py sdk: gradio sdk_version: 4.2.0 --- # Ollama ## How to create your own model Create model at first: ```shell $ ollama create mario -f ./Modelfile parsing modelfile looking for model reading model metadata creating model system layer creating parameter layer creating config layer using already created layer sha256:6ae28029995007a3ee8d0b8556d50f3b59b831074cf19c84de87acf51fb54054 using already created layer sha256:22e1b2e8dc2fbc3ac38b50f59e49f594034462c1cd02764353a8a076d97c3a59 writing layer sha256:764201e0b9bdcca5eb7e8c78351fc3b6ca97f80e875c4f32f029bbb4443b3841 writing layer sha256:bb6350cd7b66a0307635d93822c6f0e8881c3f2d4eae8dfdd46b0c662eef19c7 writing layer sha256:4100fa5c79cf0f862dc524f1f1a4415733ff482f7eb2ceabc4c97bf75ca942f9 writing manifest removing any unused layers success ``` Run the new model: ```shell $ ollama run mario >>> Who are you? I am Mario, the assistant of Super Mario Bros. It's great to meet you! How can I assist you today? >>> Tell me about where do you live? As Mario, the assistant of Super Mario Bros., I live in a magical kingdom called Mushroom Kingdom. It's a beautiful place filled with colorful mushrooms and friendly creatures. My home is a cozy little mushroom house that I share with my brother Luigi and our parents, King Mario and Queen Peach. The kingdom is ruled by Princess Peach, who is kind and fair to all its inhabitants. >>> Send a message (/? for help) >>> /bye ``` ## Build a project on the top of Ollama ```shell $ python main.py Running on local URL: http://127.0.0.1:7860 Running on public URL: https://62b836703a064858f6.gradio.live This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces) ``` Input question like `Why the sky is blue?`, and AI answers: ***The sky appears blue because of a phenomenon known as Rayleigh scattering. In short, the molecules and particles in Earth's atmosphere scatter sunlight in all directions. Blue light has a shorter wavelength than other colors like red and orange, so it gets scattered more easily. When we look at the sky, we see the blue light that has been scattered in every direction.*** ## Huggingface Space ```shell $ gpg --list-secret-keys /Users/terrence/.gnupg/pubring.kbx ---------------------------------- sec rsa4096 2020-07-18 [SC] [expires: 2024-07-18] 87C0B2CC7AB712E09F6307F1A035A79423B9DE74 uid [ultimate] Terrence Miao (Terrence Miao's PGP for GMail) ssb rsa4096 2020-07-18 [E] [expires: 2024-07-18] sec rsa4096 2021-04-20 [SC] [expires: 2025-04-20] 0D8566A0710E6628D42A270E0BFE25D4EBCEB936 uid [ultimate] Terrence Miao (Corp password) ssb rsa4096 2021-04-20 [E] [expires: 2025-04-20] $ gpg --armor --export 87C0B2CC7AB712E09F6307F1A035A79423B9DE74 -----BEGIN PGP PUBLIC KEY BLOCK----- mQINBF8Sxk4BEACyaFmodOq9Tjb1/GN3KgUy7KljvBz78P2oVfYCts+trNt3e+j6 P5aDf7ZtOOcWgyq4OKmg3rUOENdYziVUkuwsjAl/VXZsHZ9uE5vlgQjoE/0ipI5B KAenmvP5zKZ8/GiP/iWUUdc+VLQdl7PPzL4dwVhxi1Xgbi8Oek8iMzBefi+GYSv7 y/qzfnaYU/3CCQJpxyRKvuVaNucWmR4KWg5NhIldoWeNRLKQRNUw/BrNlwX/4842 JBcDkrLi/xAGVS+nRAxOFSuBM4JIFhBFPV/gvUZhbea3iAIbzYc0SMw/tVvP8OSg DFs875nFUTGlqXMTSOvAIuJd/bEiyXqoagUG9ZYjslXbLJvsbW0gG93b6EEW1TdU epzRUxEL8f6Nt3U2S4dTd1ai9iC9CnEULYcbeAk+7WhNoqE72RxwyB1jpq/SPuXv GlC9DdX7biNcRngGzo9GjR0fJxStfpsorEq5Mya3Swt6d9ZtjgU8FkW+NFSzUuvA O0spjVHwJVrm8SPkAfhUJvuuLz9tTMTUr99Xm80dkxR3NswzWsPg8DKr7zDoBDRz N8zArBEjV8BlGb1upKgEETOVnemmOsYAd1novi/felCgzTIwWZTUDrI0DGdjGp7B hztX0GXacDutls9DwavmO8P9aG1WBOVkIRD7EmYGzGFbdiFrm/hNFLAUXQARAQAB tEdUZXJyZW5jZSBNaWFvIChUZXJyZW5jZSBNaWFvJ3MgUEdQIGZvciBHTWFpbCkg PHRlcnJlbmNlLm1pYW9AZ21haWwuY29tPokCV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yB/2RZlA3BxARCwN RhF19IsQavd2BLsxRHmT/sLtllT5n1Nfc5pssh5d3jN/ZZShN2VSQCbUg/Lx7Zhk PLs6vz8ecX4AkZdp64F9ZO2B122NEvMwnWnuQwtBoqI5M0HL7AWf+6vmWDrqFkU= =NgfS -----END PGP PUBLIC KEY BLOCK----- ``` Login Hugging Face, and with a `Write` access token: ```shell $ huggingface-cli login _| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _| _|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_| _| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _| _| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_| A token is already saved on your machine. Run `huggingface-cli whoami` to get more information or `huggingface-cli logout` if you want to log out. Setting a new token will erase the existing one. To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens . Token: Add token as git credential? (Y/n) Token is valid (permission: write). Your token has been saved in your configured git credential helpers (osxkeychain). Your token has been saved to /Users/terrence/.cache/huggingface/token Login successful ``` ## References - [Ollama Is INSANE: Building Open-Source ChatGPT From Scratch (FULLY Local)](https://www.youtube.com/watch?v=rIRkxZSn-A8)