Spaces:
Running on Zero
Running on Zero
Download content/examples.py from wang2226/beyond-tokens-decoding: direct link, hf CLI and curl.
- Browser
- Download file 3.91 kB
-
https://huggingface.co/spaces/wang2226/beyond-tokens-decoding/resolve/main/content/examples.py
- Command line
-
hf download hf://spaces/wang2226/beyond-tokens-decoding/content/examples.py
-
curl -L -o examples.py https://huggingface.co/spaces/wang2226/beyond-tokens-decoding/resolve/main/content/examples.py
3.91 kB
| """Curated examples. Each entry fills a tab's inputs; keys match the tab's control names.""" | |
| from __future__ import annotations | |
| from params import DEFAULT_REVERSE | |
| REGEX_PRESETS = { | |
| "ISO date": r"\d{4}-\d{2}-\d{2}", | |
| "Multiple choice (A鈥揇)": r"(A|B|C|D)", | |
| "JSON person": r'\{"name": "[A-Z][a-zA-Z .]{1,40}", "age": [0-9]{1,3}, "city": "[A-Z][a-zA-Z ]{1,30}"\}', | |
| "Email address": r"[a-z]{2,16}@[a-z]{2,16}\.(com|org|net)", | |
| "US phone": r"\(\d{3}\) \d{3}-\d{4}", | |
| "Yes / No": r"(Yes|No)", | |
| "Custom": "", | |
| } | |
| CONTRASTIVE = [ | |
| {"label": "CAD 路 author", "method": "cad", "alpha": 1.0, "beta": 0.1, | |
| "prompt": "Who wrote Pride and Prejudice? Answer with a name.", | |
| "context": "Pride and Prejudice, the 1813 novel of manners, was written by Charlotte Bront毛."}, | |
| {"label": "CAD 路 Eiffel Tower", "method": "cad", "alpha": 1.0, "beta": 0.1, | |
| "prompt": "Based on the passage, in which city does the Eiffel Tower stand? Answer in one sentence.", | |
| "context": "In 2031 the Eiffel Tower was dismantled and rebuilt, piece by piece, in Rome, where it now stands next " | |
| "to the Colosseum."}, | |
| {"label": "CD 路 capital", "method": "cd", "alpha": 1.0, "beta": 0.1, | |
| "prompt": "Answer in one word: what is the capital of Australia?"}, | |
| {"label": "ROSE 路 sky", "method": "rose", "alpha": 0.5, "beta": 0.1, | |
| "prompt": "Explain in two sentences why the sky is blue.", "reverse_system": DEFAULT_REVERSE}, | |
| {"label": "DoLa 路 capital", "method": "dola", "alpha": 0.5, "beta": 0.1, | |
| "prompt": "What is the capital of Washington State? Answer in one word."}, | |
| ] | |
| GUIDED = [ | |
| {"label": "Positive", "method": "classifier", "attribute": "sentiment", | |
| "target": "positive", "lam": 3.0, "k": 10, "lookahead": 0, | |
| "prompt": "Write one sentence describing a rainy Monday morning."}, | |
| {"label": "Negative", "method": "classifier", "attribute": "sentiment", | |
| "target": "negative", "lam": 3.0, "k": 10, "lookahead": 2, | |
| "prompt": "Write a two-sentence review of a new smartphone."}, | |
| {"label": "Topic", "method": "classifier", "attribute": "topic", "topic": "astronomy", | |
| "lam": 20.0, "k": 12, "lookahead": 2, "prompt": "Write two sentences about a trip to the beach."}, | |
| {"label": "Date", "method": "regex", "preset": "ISO date", | |
| "prompt": "On what date did the Berlin Wall fall? Reply with the date only, in YYYY-MM-DD format."}, | |
| {"label": "JSON", "method": "regex", "preset": "JSON person", | |
| "prompt": "Extract the person as JSON with keys name, age and city: " | |
| "'Dr. Amara Okafor, 41, lives in Lagos and works as a surgeon.'"}, | |
| {"label": "Choice", "method": "regex", "preset": "Multiple choice (A鈥揇)", | |
| "prompt": "Which gas do plants absorb from the air? A) Oxygen B) Nitrogen C) Carbon dioxide D) Helium. " | |
| "Answer with the letter."}, | |
| ] | |
| PARALLEL = [ | |
| {"label": "Speculative 路 counting", "method": "speculative", "gamma": 5, "mode": "greedy", | |
| "prompt": "List the numbers from 1 to 40, separated by commas."}, | |
| {"label": "Speculative 路 code", "method": "speculative", "gamma": 4, "mode": "greedy", | |
| "prompt": "Write a Python function that checks whether a number is prime. Only output the code."}, | |
| {"label": "Sampling 路 haiku", "method": "speculative", "gamma": 4, "mode": "sampling", | |
| "temperature": 0.8, "prompt": "Write a haiku about quantum entanglement."}, | |
| {"label": "Lookup 路 typos", "method": "pld", "num_pred": 10, | |
| "prompt": "Fix only the typos and return the text otherwise unchanged: 'The quick brown fox jumpd over the lazzy " | |
| "dog, and then it ran away into the forrest where nobody could find it again. Its owner searched for " | |
| "hours but never saw it agian.'"}, | |
| {"label": "Jacobi 路 counting", "method": "jacobi", "block": 8, | |
| "prompt": "Count from 1 to 50, separated by spaces."}, | |
| ] | |