import json import os from io import BytesIO import gradio as gr from huggingface_hub import upload_file default_question = """ We're going to use the wikitext (link) dataset with the distilbert-base-cased (link) model checkpoint.

Start by loading the wikitext-2-raw-v1 version of that dataset, and take the 11th example (index 10) of the train split.
We'll tokenize this using the appropriate tokenizer, and we'll mask the sixth token (index 5) the sequence.

When using the distilbert-base-cased checkpoint to unmask that (sixth token, index 5) token, what is the most probable predicted token (please provide the decoded token, and not the ID)?

Tips:
- You might find the transformers docs (link) useful.
- You might find the datasets docs (link) useful.
- You might also be interested in the Hugging Face course (link). """ skops_question = """ 1. Create a python environment[1] and install `scikit-learn` version `1.0` in that environment.
2. Using that environment, create a `LogisticRegression` model[2] and fit it on the Iris dataset[3].
3. Save the trained model using `pickle`[4] or `joblib`[5].
4. Create a second environment, and install `scikit-learn` version `1.1` in it.
5. Try loading the model you saved in step 3 in this second environment.

Question:
Is there a warning or error you receive while trying to load the model? If yes, what exactly is it.

References
- [1] You can use any tool you want to create the environment. Two of the options are:
- `venv`: https://docs.python.org/3/library/venv.html
- `mamba`: https://github.com/mamba-org/mamba
- [2] `LogisticRegression` API guide: https://scikit-learn.org/dev/modules/generated/sklearn.linear_model.LogisticRegression.html
- [3] `load_iris` API guide: https://scikit-learn.org/dev/modules/generated/sklearn.datasets.load_iris.html
- [4] `pickle`: https://docs.python.org/3/library/pickle.html
- [5] - `joblib`: https://joblib.readthedocs.io/en/latest/ """ internships = { 'Accelerate': default_question, 'Diffusion distillation': default_question, 'Skops & Scikit-Learn': skops_question, "Code Generation": default_question, "Document AI Democratization": default_question, "Evaluate": default_question, "ASR": default_question, "Efficient video pretraining": default_question, "Embodied AI": default_question, "Emergence of scene and text understanding": default_question, "Everything is multimodal": default_question, "Everything is vision": default_question, "Retrieval augmentation as prompting": default_question, "Social impact evaluations": default_question, "Toolkit for detecting distribution shift": default_question, "AI Art Tooling Residency": default_question, "Gradio as an ecosystem": default_question, } with gr.Blocks() as demo: gr.Markdown( """ # Internship introduction Please select the internship you would like to apply to and answer the question asked in the Answer box. """ ) internship_choice = gr.Dropdown(label='Internship', choices=list(internships.keys())) with gr.Column(visible=False) as details_col: summary = gr.HTML(label='Question') details = gr.Textbox(label="Answer") username = gr.Textbox(label="Hugging Face Username") comment = gr.Textbox(label="Any comment?") generate_btn = gr.Button("Submit") output = gr.Label() def filter_species(species): return gr.Label.update( internships[species] ), gr.update(visible=True) internship_choice.change(filter_species, internship_choice, [summary, details_col]) def on_click(_details, _username, _internship_choice, _comment): response = {'response': _details, "internship": _internship_choice, "comment": _comment} upload_file( path_or_fileobj=BytesIO(bytes(json.dumps(response), 'utf-8')), path_in_repo=_username, repo_id='internships/internships-2023', repo_type='dataset', token=os.environ['HF_TOKEN'] ) return f"Submitted: '{_details}' for user '{_username}'" generate_btn.click(on_click, inputs=[details, username, internship_choice, comment], outputs=[output]) if __name__ == "__main__": demo.launch()