This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from bert_score import BERTScorer | |
| def calculate_bert_score(generated_answers, ground_truth): | |
| scorer = BERTScorer(model_type='bert-base-uncased') | |
| P, R, F1 = scorer.score(generated_answers, ground_truth) | |
| for i, (p, r, f1) in enumerate(zip(P, R, F1)): | |
| print(f"Pair {i + 1} - BERTScore Precision: {p.mean():.4f}, Recall: {r.mean():.4f}, F1: {f1.mean():.4f}") | |
| avg_precision = sum(p.mean() for p in P) / len(P) | |
| avg_recall = sum(r.mean() for r in R) / len(R) | |
| avg_f1 = sum(f1.mean() for f1 in F1) / len(F1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from rouge_score import rouge_scorer | |
| def calculate_rouge_scores(generated_answers, ground_truth): | |
| scorer = rouge_scorer.RougeScorer(['rouge1', 'rouge2', 'rougeL'], use_stemmer=True) | |
| total_rouge1, total_rouge2, total_rougeL = 0, 0, 0 | |
| for gen, ref in zip(generated_answers, ground_truth): | |
| scores = scorer.score(gen, ref) | |
| total_rouge1 += scores['rouge1'].fmeasure | |
| total_rouge2 += scores['rouge2'].fmeasure | |
| total_rougeL += scores['rougeL'].fmeasure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from nltk.translate.bleu_score import corpus_bleu | |
| def calculate_bleu_score(machine_results, reference_texts): | |
| bleu_score = corpus_bleu([[ref.split()] for ref in reference_texts], [gen.split() for gen in machine_results]) | |
| print(f'BLEU Score: {bleu_score}') | |
| # BLEU Score for Finetuned: | |
| # BLEU Score: 0.2119600445859861 | |
| # BLEU Score for Non-Finetuned: | |
| # BLEU Score: 0.11573503531718608 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| You will act as a synthetic instruction data generator based on the given URL. Generate a minimum of 15 synthetic data which is intended to be a comprehensive or exhaustive treatment of the subject matter.. | |
| * Please act as a tutor and create a high quality detailed synthetic questions and answers from only using the context provided by the user. | |
| * Ensure data teaches concepts step-by-step and focusses in improving reasoning skills. | |
| * Focus on generating questions and answers about under-represented topics and knowledge gaps. | |
| * Generate multiple combinations for detailed questions and answers such that the entire context is covered in the generated synthetic data | |
| Generate a Microsoft Excel - CSV compatible response with below columns separated by, and text in double quotes | |
| 1. 'instruction': | |
| * Ask a clear question related to the topics that requires logical thinking or common sense reasoning |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.web3j.crypto.Credentials; | |
| import org.web3j.protocol.Web3j; | |
| import org.web3j.protocol.core.DefaultBlockParameterName; | |
| import org.web3j.protocol.core.methods.response.EthBlock; | |
| import org.web3j.protocol.http.HttpService; | |
| import org.web3j.token.Token; | |
| import org.web3j.tx.gas.ContractGasProvider; | |
| import org.web3j.tx.gas.StaticGasProvider; | |
| class SmartContractFetchBalance { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.ethereum.smartcontract.utils.Constants; | |
| import com.ethereum.smartcontract.utils.Web3JUtils; | |
| import org.web3j.crypto.Credentials; | |
| import org.web3j.protocol.Web3j; | |
| import org.web3j.protocol.core.DefaultBlockParameterName; | |
| import org.web3j.protocol.core.methods.response.EthBlock; | |
| import org.web3j.protocol.http.HttpService; | |
| import org.web3j.token.Token; | |
| import org.web3j.tx.gas.ContractGasProvider; | |
| import org.web3j.tx.gas.StaticGasProvider; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plugins { | |
| //other plugins go here | |
| id 'java' | |
| id 'org.web3j' version '4.8.7' //Web3J Plugin to interact with Smart Contract | |
| } | |
| solidity { | |
| executable = './src/main/resources/solc-windows.exe' // Path to Solc Compiler file | |
| version = '0.8.0' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //called only once after the page loads or is refreshed | |
| useEffect(() => { | |
| async function setup() { | |
| const name = await loadContractName(); | |
| setName(name); | |
| const symbol = await loadContractSymbol(); | |
| setSymbol(symbol); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // alchemy key from .env file | |
| const alchemyKey = process.env.REACT_APP_ALCHEMY_KEY; | |
| // load alchemy web3.js dependency | |
| const { createAlchemyWeb3 } = require("@alch/alchemy-web3"); | |
| // configure web3js to use alchemy key | |
| const web3 = createAlchemyWeb3(alchemyKey); | |
| // load the contract abi [contract abi] | |
| const contractABI = require("../contract-abi.json"); | |
| // deployed smart contract address from .env file | |
| const contractAddress = process.env.REACT_APP_CONTRACT_ADDRESS; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| REACT_APP_ALCHEMY_KEY = https://eth-ropsten.ws.alchemyapi.io/v2/<key> | |
| REACT_APP_CONTRACT_ADDRESS=<deployed contract address> |
NewerOlder