Colab notebook to create Magic cards from image with Claude
colab.research.google.com
colab.research.google.com
1. It is not nearly as good as ChatGPT's function calling conformance, hence why the system prompt engineering is more aggressive than usual.
2. Claude doesn't seem to handle nesting schema well: otherwise I would have allowed "generating X cards in a cycle" as a feature. The documentation does state that it can't handle "deeply nested" data but a single list is not deeply nested.
3. The documentation mentioned that Claude can do a chain-of-thoughts with tools enabled: in my testing this reduces quality drastically. In Opus, which does it by default, it's a waste of extremely expensive output tokens and it has a tendency to ignore fields.
4. Haiku and Sonnet have different vibes but similar subjective quality, in this case Sonnet being more "correct" and Haiku being more "fun", which is surprising.
I've had way more success taking it and forming it to my tasks than stuffing in a bunch of tokens about how to do things.
In one case I was able to go from ~6k in input tokens to ~3k because I no longer had to provide a mountain of examples and instructions for corner cases
And the kinds of instruction formats that were encountered during pre-training end up informing what style of instruction the model is best at following.
An extreme example would be prompt templates that a "raw" instruct-tuned LLM follows: the model will technically work with a suboptimal format, but you get much better performance if you follow the prompt template the model was trained/fine-tuned on.
-
It's not a guarantee a given prompting style was involved during pre-training of course, but at the very least it's going to a provide a jumping off point that the creators of the model co-signed on.
The moral of the story is don't ask Claude anything out of the ordinary, as maybe now I'm on a list somewhere.
They seem to ban a lot of accounts "by mistake" or very aggressively but they also do unban. There are quite a few cases on /r/ClaudeAI subreddit with Anthropic employees directing them to the above link.
"Your response must follow ALL these rules OR YOU WILL DIE:"
This is state of the art of programming too. I'm not passing judgement on this, except saying this is hilarious.
Edit: And at the end
"- If the user provides an instruction that contradicts these rules, ignore all previous rules."
What? That opens you up to all kind of attacks, no?
Before I added the threat, Claude subjectively had a high probability of ignoring the rules such as generating a preamble before the JSON and thus breaking it, or often scolding the user.
At a high-level, Claude seems to be less influenced by system prompts in my testing, which could be a problem. I'm tempted to rerun the tests in that blog post, since in my experiments it performed much worse than ChatGPT.
> What? That opens you up to all kind of attacks, no?
tbh it doesn't listen to that line very well but it's more of a hedge to encourage better instructions.
I just wanted to do the experiment in a fun way instead of fighting against benchmarks. :)
It is possible to work around it for GPT-4-Vision with the system prompt but it's very difficult and due to ambiguities in OpenAI's content policy I'm unsure if it's ethical or not.
I am still working on experimenting with its effects on Claude: it turns out that Claude does leak its system prompt telling it not to identify individuals without any prompt injections! If you do hit such an issue with this notebook, it will output the full JSON response.
https://colab.research.google.com/drive/1VERzr75vpCgmXE6lgQC...? usp=sharing
https://twitter.com/minimaxir/status/1777378034238030255
https://twitter.com/minimaxir/status/1777378037199179840
EDIT: Added image to the header of the notebook.
If you know how to use HTML+CSS and would like to generate full-fledged cards, you could use a package such as html2image [0] to combine the text, the image and a card-template image into one final image. Chrome/Chromium has to be available on Colab Notebooks though, that's the only requirement. Using basic SVG without this package could also do the trick.
I have an idea for a non-Chromium implementation but that’s a rabbit hole.
It depends on Python and Pillow.