What I do is convert to markdown, that way you still get some semantic structure. Even built an Elixir library for this: https://github.com/agoodway/html2markdown
Minifying HTML for GPT-4o: Remove all the HTML tags
21–30 of 52 posts
Re: Minifying HTML for GPT-4o: Remove all the HTML tags
#22Re: Minifying HTML for GPT-4o: Remove all the HTML tags
#23Isn't GPT-4o multimodal? Shouldn't I be able to just feed in an image of the rendered HTML, instead of doing work to strip tags out?
it is theoretically possible, but the results and bandwidth would be worse. sending an image that large would take a lot longer than sending text
Re: Minifying HTML for GPT-4o: Remove all the HTML tags
#24By default it will strip all HTML tags and return just the text:
curl 'https://simonwillison.net/' | strip-tags
But you can also tell it you just want to get back the area of a page identified by one or more CSS selectors: curl 'https://simonwillison.net/' | strip-tags .quote
Or you can ask it to keep specific tags if you think those might help provide extra context to the LLM: curl 'https://simonwillison.net/' | strip-tags .quote -t div -t blockquote
Add "-m" to minify the output (basically stripping most whitespace)Running this command:
curl 'https://simonwillison.net/' | strip-tags .quote -t div -t blockquote -m
Gives me back output that starts like this: history | tail -n
2000 | llm -s "Write aliases for my zshrc based on my
terminal history. Only do this for most common features.
Don't use any specific files or directories."
—
anjor #
3:01 pm
/ ai, generative-ai, llms, llm
Art is notoriously
hard to define, and so are the differences between good art
and bad art. But let me offer a generalization: art is
something that results from making a lot of choices. […] to
oversimplify, we can imagine that a ten-thousand-word short
story requires something on the order of ten thousand
choices. When you give a generative-A.I. program a prompt,
you are making very few choices; if you supply a hundred-word
prompt, you have made on the order of a hundred choices. If
an A.I. generates a ten-thousand-word story based on your
prompt, it has to fill in for all of the choices that you are
not making.
— Ted Chiang #
10:09 pm
/ art, new-yorker, ai, generative-ai, ted-chiang
I also often use the https://r.jina.ai/ proxy - add a URL to that and it extracts the key content (using Puppeteer) and returns it converted to Markdown, e.g. https://r.jina.ai/https://simonwillison.net/2024/Sep/2/anato...Re: Minifying HTML for GPT-4o: Remove all the HTML tags
#25This results in a kind of innerText you get in browsers, great and light to pass into LLMs.
defp extract_inner_text(html) do
html
|> Floki.parse_document!()
|> Floki.find("body")
|> Floki.traverse_and_update(fn
{tag, _attrs, _children} = _node when tag in ["script", "style"] ->
nil
node ->
node
end)
|> Floki.text(sep: " ")
|> String.trim()
|> String.replace(~r/\s+/, " ")
endRe: Minifying HTML for GPT-4o: Remove all the HTML tags
#26Isn't GPT-4o multimodal? Shouldn't I be able to just feed in an image of the rendered HTML, instead of doing work to strip tags out?
Re: Minifying HTML for GPT-4o: Remove all the HTML tags
#27ChatGPT is clearly trained on wikipedia, is there any concern about its knowledge from there polluting the responses? Seems like it would be better to try against data it didn't potentially already know.
Re: Minifying HTML for GPT-4o: Remove all the HTML tags
#28There are a few optimizations we can make:
- trip all content in and - use Readability.js for articles - extract structured content from oEmbed
It works surprisingly well for me, even with gpt-4o-mini
Re: Minifying HTML for GPT-4o: Remove all the HTML tags
#29 name=john,age=23
name=anna,age=26
Rather than this: {
matches: [
{ name: "john", age: 23 },
{ name: "anna", age: 26 }
]
}