└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Language models on the command-line 2 | 3 | Notes for a talk I gave at [Mastering LLMs: A Conference For Developers & Data Scientists](https://maven.com/parlance-labs/fine-tuning). 4 | 5 | Here is the [full 67 minute talk video](https://twitter.com/hamelhusain/status/1800741994899394612). 6 | 7 | - [Datasette](https://datasette.io/) 8 | - [My blog](https://simonwillison.net/) 9 | - [LLM](https://llm.datasette.io/en/stable/) 10 | 11 | ## Getting started 12 | 13 | ```bash 14 | brew install llm # or pipx or pip 15 | llm keys set openai 16 | # paste key here 17 | llm "Say hello in Spanish" 18 | ``` 19 | ## Installing Claude 3 20 | ```bash 21 | llm install llm-claude-3 22 | llm keys set claude 23 | # Paste key here 24 | llm -m haiku 'Say hello from Claude Haiku' 25 | ``` 26 | 27 | ## Local model with llm-gpt4all 28 | 29 | ```bash 30 | llm install llm-gpt4all 31 | llm models 32 | llm chat -m mistral-7b-instruct-v0 33 | ``` 34 | ## Browsing logs with Datasette 35 | 36 | https://datasette.io/ 37 | 38 | ```bash 39 | pipx install datasette # or brew or pip 40 | datasette "$(llm logs path)" 41 | # Browse at http://127.0.0.1:8001/ 42 | ``` 43 | ### Templates 44 | ```bash 45 | llm --system 'You are a sentient cheesecake' -m gpt-4o --save cheesecake 46 | ``` 47 | Now you can chat with a cheesecake: 48 | ```bash 49 | llm chat -t cheesecake 50 | ``` 51 | 52 | More plugins: https://llm.datasette.io/en/stable/plugins/directory.html 53 | 54 | ### llm-cmd 55 | 56 | Help with shell commands. Blog entry is here: https://simonwillison.net/2024/Mar/26/llm-cmd/ 57 | 58 | ### files-to-prompt and shot-scraper 59 | 60 | `files-to-prompt` is described here: 61 | https://simonwillison.net/2024/Apr/8/files-to-prompt/ 62 | 63 | `shot-scraper javascript` documentation: https://shot-scraper.datasette.io/en/stable/javascript.html 64 | 65 | JSON output for Google search results: 66 | 67 | ```bash 68 | shot-scraper javascript 'https://www.google.com/search?q=nytimes+slop' ' 69 | Array.from( 70 | document.querySelectorAll("h3"), 71 | el => ({href: el.parentNode.href, title: el.innerText}) 72 | )' 73 | ``` 74 | This version gets the HTML that includes the snippet summaries, then pipes it to LLM to answer a question: 75 | ```bash 76 | shot-scraper javascript 'https://www.google.com/search?q=nytimes+slop' ' 77 | () => { 78 | function findParentWithHveid(element) { 79 | while (element && !element.hasAttribute("data-hveid")) { 80 | element = element.parentElement; 81 | } 82 | return element; 83 | } 84 | return Array.from( 85 | document.querySelectorAll("h3"), 86 | el => findParentWithHveid(el).innerText 87 | ); 88 | }' | llm -s 'describe slop' 89 | ``` 90 | ### Hacker news summary 91 | 92 | https://til.simonwillison.net/llms/claude-hacker-news-themes describes my Hacker News summary script in detail. 93 | 94 | ### Embeddings 95 | 96 | Full documentation: https://llm.datasette.io/en/stable/embeddings/index.html 97 | 98 | I ran this: 99 | 100 | ```bash 101 | curl -O https://datasette.simonwillison.net/simonwillisonblog.db 102 | llm embed-multi links \ 103 | -d simonwillisonblog.db \ 104 | --sql 'select id, link_url, link_title, commentary from blog_blogmark' \ 105 | -m 3-small --store 106 | ``` 107 | Then looked for items most similar to a string like this: 108 | ```bash 109 | llm similar links \ 110 | -d simonwillisonblog.db \ 111 | -c 'things that make me angry' 112 | ``` 113 | 114 | ### More links 115 | 116 | - [Coping strategies for the serial project hoarder](https://simonwillison.net/2022/Nov/26/productivity/) talk about personal productivity on different projects 117 | - [Figure out how to serve an AWS Lambda function with a Function URL from a custom subdomain](https://github.com/simonw/public-notes/issues/1) as an example of how I use GitHub Issues 118 | --------------------------------------------------------------------------------