ctizzzy0 commited on
Commit
54c51b7
·
verified ·
1 Parent(s): 1ea6efe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -19
app.py CHANGED
@@ -1,19 +1,3 @@
1
-
2
- # CollegeGenius HF — 100% Hugging Face, No External APIs
3
- # ------------------------------------------------------
4
- # Everything runs inside the Space using open models from the Hugging Face Hub.
5
- # No third‑party web APIs or keys required.
6
- #
7
- # Models:
8
- # - sentence-transformers/paraphrase-MiniLM-L6-v2 (embeddings)
9
- # - textattack/roberta-base-CoLA (grammar acceptability per sentence)
10
- # - sshleifer/distilbart-cnn-12-6 (summarization / light rewriting)
11
- # - j-hartmann/emotion-english-distilroberta-base (emotion for interviews)
12
- # - distilroberta-base (masked LM for resume verb suggestions)
13
- #
14
- # Launch config is at bottom: demo.queue(...).launch()
15
- # ------------------------------------------------------
16
-
17
  import os
18
  import re
19
  import io
@@ -65,7 +49,8 @@ _EMBEDDER = SentenceTransformer("sentence-transformers/paraphrase-MiniLM-L6-v2")
65
  # Grammar acceptability (CoLA)
66
  _CoLA_tok = AutoTokenizer.from_pretrained("textattack/roberta-base-CoLA")
67
  _CoLA = AutoModelForSequenceClassification.from_pretrained("textattack/roberta-base-CoLA")
68
- _acc_pipe = pipeline("text-classification", model=_CoLA, tokenizer=_CoLA_tok, return_all_scores=True)
 
69
 
70
  # Summarizer / lightweight rewriting
71
  _SUM_tok = AutoTokenizer.from_pretrained("sshleifer/distilbart-cnn-12-6")
@@ -161,7 +146,8 @@ CLICHES = [
161
  ]
162
 
163
  def acceptability_score(sentence: str) -> float:
164
- out = _acc_pipe(sentence)[0]
 
165
  scores = {o["label"]: o["score"] for o in out}
166
  return float(scores.get("LABEL_1", 0.0))
167
 
@@ -669,4 +655,5 @@ with gr.Blocks(title="CollegeGenius HF", theme=gr.themes.Soft()) as demo:
669
  app = demo
670
 
671
  if __name__ == "__main__":
672
- demo.queue(concurrency_count=2, max_size=32).launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import re
3
  import io
 
49
  # Grammar acceptability (CoLA)
50
  _CoLA_tok = AutoTokenizer.from_pretrained("textattack/roberta-base-CoLA")
51
  _CoLA = AutoModelForSequenceClassification.from_pretrained("textattack/roberta-base-CoLA")
52
+ # Use top_k=None instead of deprecated return_all_scores=True
53
+ _acc_pipe = pipeline("text-classification", model=_CoLA, tokenizer=_CoLA_tok, top_k=None)
54
 
55
  # Summarizer / lightweight rewriting
56
  _SUM_tok = AutoTokenizer.from_pretrained("sshleifer/distilbart-cnn-12-6")
 
146
  ]
147
 
148
  def acceptability_score(sentence: str) -> float:
149
+ out = _acc_pipe(sentence)[0] # list of dicts with 'label' and 'score'
150
+ # When top_k=None, pipeline returns all class scores
151
  scores = {o["label"]: o["score"] for o in out}
152
  return float(scores.get("LABEL_1", 0.0))
153
 
 
655
  app = demo
656
 
657
  if __name__ == "__main__":
658
+ # Gradio 4+ no longer accepts concurrency_count here
659
+ demo.queue().launch()