Spaces:
Sleeping
Sleeping
marme
commited on
Commit
·
ada59c2
1
Parent(s):
eb5fab4
add model dropdown
Browse files
app.py
CHANGED
|
@@ -2,20 +2,21 @@ import gradio as gr
|
|
| 2 |
|
| 3 |
from chonky import ParagraphSplitter
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
with gr.Blocks() as demo:
|
| 8 |
gr.Markdown("# Semantic Chunking Demo\n **Note**: This Space runs on CPU only, so input is limited to max. 50000 characters.")
|
| 9 |
-
gr.
|
| 10 |
-
|
| 11 |
-
</footer>""")
|
| 12 |
button = gr.Button("Run", variant="primary")
|
| 13 |
text = gr.Textbox(label='Input Text', max_length=50000)
|
| 14 |
gr.Markdown("## Result chunks:")
|
| 15 |
chunks = gr.Markdown()
|
| 16 |
|
| 17 |
-
button.click(
|
| 18 |
-
|
| 19 |
|
| 20 |
|
| 21 |
if __name__ == "__main__":
|
|
|
|
| 2 |
|
| 3 |
from chonky import ParagraphSplitter
|
| 4 |
|
| 5 |
+
|
| 6 |
+
def run(text, model_id):
|
| 7 |
+
splitter = ParagraphSplitter(model_id=model_id)
|
| 8 |
+
return "\n\n---\n\n".join(splitter(text))
|
| 9 |
|
| 10 |
with gr.Blocks() as demo:
|
| 11 |
gr.Markdown("# Semantic Chunking Demo\n **Note**: This Space runs on CPU only, so input is limited to max. 50000 characters.")
|
| 12 |
+
model = gr.Dropdown(label="Choose model", value="mamei16/chonky_distilbert_base_uncased_1.1",
|
| 13 |
+
choices=["mamei16/chonky_distilbert_base_uncased_1.1", "mirth/chonky_distilbert_base_uncased_1", "mirth/chonky_modernbert_base_1"])
|
|
|
|
| 14 |
button = gr.Button("Run", variant="primary")
|
| 15 |
text = gr.Textbox(label='Input Text', max_length=50000)
|
| 16 |
gr.Markdown("## Result chunks:")
|
| 17 |
chunks = gr.Markdown()
|
| 18 |
|
| 19 |
+
button.click(run, [text, model], chunks)
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
if __name__ == "__main__":
|