Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,11 +24,11 @@ word_vectors = api.load("glove-wiki-gigaword-50")
|
|
| 24 |
# Check for GPU and set the device accordingly
|
| 25 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 26 |
|
| 27 |
-
# Load AI Detector model and tokenizer from Hugging Face (
|
| 28 |
-
tokenizer_ai = AutoTokenizer.from_pretrained("
|
| 29 |
-
model_ai = AutoModelForSequenceClassification.from_pretrained("
|
| 30 |
|
| 31 |
-
# AI detection function using
|
| 32 |
def detect_ai_generated(text):
|
| 33 |
inputs = tokenizer_ai(text, return_tensors="pt", truncation=True, max_length=512).to(device)
|
| 34 |
with torch.no_grad():
|
|
@@ -63,13 +63,13 @@ def capitalize_sentences_and_nouns(text):
|
|
| 63 |
|
| 64 |
return ' '.join(corrected_text)
|
| 65 |
|
| 66 |
-
# Paraphrasing function using
|
| 67 |
def paraphrase_with_spacy_nltk(text):
|
| 68 |
doc = nlp(text)
|
| 69 |
paraphrased_words = []
|
| 70 |
|
| 71 |
for token in doc:
|
| 72 |
-
# Map
|
| 73 |
pos = None
|
| 74 |
if token.pos_ in {"NOUN"}:
|
| 75 |
pos = wordnet.NOUN
|
|
|
|
| 24 |
# Check for GPU and set the device accordingly
|
| 25 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 26 |
|
| 27 |
+
# Load AI Detector model and tokenizer from Hugging Face (e.g., GPT-Neo)
|
| 28 |
+
tokenizer_ai = AutoTokenizer.from_pretrained("EleutherAI/gpt-neo-2.7B")
|
| 29 |
+
model_ai = AutoModelForSequenceClassification.from_pretrained("EleutherAI/gpt-neo-2.7B").to(device)
|
| 30 |
|
| 31 |
+
# AI detection function using GPT-Neo-based model
|
| 32 |
def detect_ai_generated(text):
|
| 33 |
inputs = tokenizer_ai(text, return_tensors="pt", truncation=True, max_length=512).to(device)
|
| 34 |
with torch.no_grad():
|
|
|
|
| 63 |
|
| 64 |
return ' '.join(corrected_text)
|
| 65 |
|
| 66 |
+
# Paraphrasing function using SpaCy and NLTK
|
| 67 |
def paraphrase_with_spacy_nltk(text):
|
| 68 |
doc = nlp(text)
|
| 69 |
paraphrased_words = []
|
| 70 |
|
| 71 |
for token in doc:
|
| 72 |
+
# Map SpaCy POS tags to WordNet POS tags
|
| 73 |
pos = None
|
| 74 |
if token.pos_ in {"NOUN"}:
|
| 75 |
pos = wordnet.NOUN
|