Views
No views yet
1from transformers import *
2import numpy as np
3import pandas as pd
4import os
5import torch
6import torch.nn as nn
7
8model = AutoModelForSequenceClassification.from_pretrained("LDKSolutions/chatgpt-qa-detector-deberta-v3-large", num_labels=2)
9tokenizer = AutoTokenizer.from_pretrained("LDKSolutions/chatgpt-qa-detector-deberta-v3-large")
10
11model.eval()
12
13prompt = "What do you think about Bitcoin?"
14explanation = ''' As an AI language model, I do not have personal opinions or emotions. However, I can provide information and insights about Bitcoin.
15
16Bitcoin is a decentralized digital currency that operates on a peer-to-peer network, without the need for intermediaries such as banks or financial institutions. It was created in 2009 by an unknown person or group using the pseudonym Satoshi Nakamoto.
17
18Bitcoin has gained popularity as a means of exchange and a store of value, with some proponents seeing it as a potential alternative to traditional fiat currencies. However, it has also been subject to criticism due to its perceived lack of regulation and potential use in illegal activities.
19
20From a technical standpoint, Bitcoin is based on blockchain technology, a distributed ledger that records all transactions made on the network. The blockchain ensures that transactions are secure and transparent, while also allowing for anonymity.
21
22Like any investment or asset, Bitcoin has its risks and potential rewards. Its value can be volatile and subject to market fluctuations, and there is no guarantee of returns. It is important to do thorough research and seek professional advice before making any investment decisions.
23'''
24
25encoded_input = tokenizer(prompt, explanation, max_length=512, truncation=True, padding="max_length", return_tensors="pt")
26
27with torch.no_grad():
28 output = model(**encoded_input).logits
29 probs = nn.Softmax(dim=1)(output)
30 predicted_class = torch.argmax(probs).item()
31 if predicted_class == 1:
32 print("Likely to be generated by ChatGPT!")
33 else:
34 print("Likely to be generated by Human!")
35