Views
No views yet
pip install -U sentence-transformers1from sentence_transformers import CrossEncoder
2
3# Download from the 🤗 Hub
4model = CrossEncoder("cross_encoder_model_id")
5# Get scores for pairs of texts
6pairs = [
7 ["For the goalie who had the most shutouts in 2010, what's his catching hand? the most shutouts refers to max(SHO); shootCatch = 'L' refers to lefthand; shootCatch = 'R' refers to righthand; shootCatch = 'null' or 'empty' means this player is good at both left and right hand", '/* Table: TeamsPost | tmID → Teams: team ID; year → Teams; lgID: league ID; G: Games; W: wins; L: loses; T: ties; GF: goals for; GA: goals against; PIM: penalty minutes; BenchMinor: Bench minors (minutes); PPG: Power play goals; PPC: Power play chances; SHA: Shorthanded goals against; PKG: Power play goals against; PKC: Penalty kill chances; SHF: Shorthanded goals for; on */\nCREATE TABLE TeamsPost\n(\n year INTEGER not null,\n lgID TEXT, -- league ID\n tmID TEXT not null, -- team ID\n G INTEGER, -- Games\n W INTEGER, -- wins\n L INTEGER, -- loses\n T INTEGER, -- ties\n GF INTEGER, -- goals for\n GA INTEGER, -- goals against\n PIM TEXT, -- penalty minutes\n BenchMinor TEXT, -- Bench minors (minutes)\n PPG TEXT, -- Power play goals\n PPC TEXT, -- Power play chances\n SHA TEXT, -- Shorthanded goals against\n PKG TEXT, -- Power play goals against\n PKC TEXT, -- Penalty kill chances\n SHF TEXT, -- Shorthanded goals for\n primary key (year, tmID),\n foreign key (year, tmID) references Teams (year, tmID)\n on update cascade on delete cascade\n)\n-- Approximate rows: 927\n-- Sample values for column `year`: 1913, 1962, 2011\n-- Sample values for column `lgID`: NHA, NHL, PCHA\n-- Sample values for column `tmID`: MOC, TBS, MOW\n-- Sample values for column `G`: 2, 14, 26\n-- Sample values for column `W`: 0, 8, 16\n-- Sample values for column `L`: 0, 6, 11\n-- Sample values for column `T`: 0, 2, 4\n-- Sample values for column `GF`: 0, 45, 98\n-- Sample values for column `GA`: 0, 38, 91\n-- Sample values for column `PIM`: 59, 68, 87\n-- Sample values for column `BenchMinor`: 0, 6, 2\n-- Sample values for column `PPG`: 1, 5, 9\n-- Sample values for column `PPC`: 39, 27, 25\n-- Sample values for column `SHA`: 0, 1, 2\n-- Sample values for column `PKG`: 3, 8, 4\n-- Sample values for column `PKC`: 55, 45, 20\n-- Sample values for column `SHF`: 0, 1, 3\n-- Table profile: 927 rows\n-- Profile for `year`: 0% null; 97 distinct (high-cardinality); range 1913..2011, avg 1976.14\n-- Profile for `lgID`: 0% null; 5 distinct (categorical); len 3..4; top: NHL(91%), WHA(6%), PCHA(2%)\n-- Profile for `tmID`: 0% null; 77 distinct (high-cardinality); len 3..3\n-- Profile for `G`: 0% null; 25 distinct (high-cardinality); range 2..26, avg 8.81\n-- Profile for `W`: 0% null; 17 distinct (high-cardinality); range 0..16, avg 4.37\n-- Profile for `L`: 0% null; 12 distinct (high-cardinality); range 0..11, avg 4.37\n-- Profile for `T`: 0% null; 5 distinct (categorical); range 0..4, avg 0.08; top: 0(94%), 1(5%), 2(1%)\n-- Profile for `GF`: 0% null; 91 distinct (high-cardinality); range 0..98, avg 25.6\n-- Profile for `GA`: 0% null; 77 distinct (high-cardinality); range 0..91, avg 25.6\n-- Profile for `PIM`: 9% null; 342 distinct (high-cardinality); len 1..3\n-- Profile for `BenchMinor`: 38% null; 8 distinct (categorical); len 1..2; top: 0(47%), 2(28%), 4(15%)\n-- Profile for `PPG`: 31% null; 31 distinct (high-cardinality); len 1..2\n-- Profile for `PPC`: 37% null; 115 distinct (high-cardinality); len 1..3\n-- Profile for `SHA`: 35% null; 9 distinct (categorical); len 1..1; top: 0(41%), 1(31%), 2(15%)\n-- Profile for `PKG`: 31% null; 27 distinct (high-cardinality); len 1..2\n-- Profile for `PKC`: 37% null; 113 distinct (high-cardinality); len 1..3\n-- Profile for `SHF`: 31% null; 11 distinct (high-cardinality); len 1..2'],
8 ["What is the percentage of act number 5 in Titus Andronicus? act number 5 refers to Act = 5; Titus Andronicus refers to Title = 'Titus Andronicus'; percentage = divide(sum(Act = 5), count(Act)) as percentage", '/* Table: state_sector_details | level: Level of institution; stateid: state id; control: Public, Private not-for-profit, Private for-profit; state: state name; counted_pct: counted percentage; awards_per_state_value: awards per state value; awards_per_natl_value: awards per national value; exp_award_state_value: expected award state value; exp_award_natl_value: expected award national value; state_appr_value: state appropriation value; references; state_post; schools_count; state_appr_rank; grad_rate_rank; awards_per_rank */\nCREATE TABLE "state_sector_details"\n(\n stateid INTEGER, -- state id\n state TEXT -- state name\n references institution_details (state),\n state_post TEXT,\n level TEXT, -- Level of institution | Values: 4-year: bachelor\'s degree 2-year: associate\'s degree\n control TEXT, -- Values: Public, Private not-for-profit, Private for-profit\n schools_count INTEGER,\n counted_pct TEXT, -- counted percentage\n awards_per_state_value TEXT, -- awards per state value\n awards_per_natl_value REAL, -- awards per national value\n exp_award_state_value TEXT, -- expected award state value\n exp_award_natl_value INTEGER, -- expected award national value\n state_appr_value TEXT, -- state appropriation value\n state_appr_rank TEXT,\n grad_rate_rank TEXT,\n awards_per_rank TEXT,\n primary key (stateid, level, control)\n)\n-- Approximate rows: 312\n-- Sample values for column `stateid`: 0, 29, 56\n-- Sample values for column `state`: United States, Alabama, Alaska\n-- Sample values for column `state_post`: U.S., Ala., Alaska\n-- Sample values for column `level`: 2-year, 4-year\n-- Sample values for column `control`: Private for-profit, Private not-for-profit, Public\n-- Sample values for column `schools_count`: 0, 32, 1180\n-- Sample values for column `counted_pct`: NULL, 61, 62\n-- Sample values for column `awards_per_state_value`: NULL, 18.8, 17.8\n-- Sample values for column `awards_per_natl_value`: 16.5, 24.6, 32.8\n-- Sample values for column `exp_award_state_value`: NULL, 75743, 92268\n-- Sample values for column `exp_award_natl_value`: 24795, 38763, 101725\n-- Sample values for column `state_appr_value`: NULL, 290.68, 496.78\n-- Sample values for column `state_appr_rank`: NULL, 11, 2\n-- Sample values for column `grad_rate_rank`: 23, 18, 8\n-- Sample values for column `awards_per_rank`: NULL, 42, 49\n-- Table profile: 312 rows\n-- Profile for `stateid`: 0% null; 52 distinct (high-cardinality); range 0..56, avg 28.4\n-- Profile for `state`: 0% null; 52 distinct (high-cardinality); len 4..20\n-- Profile for `state_post`: 0% null; 52 distinct (high-cardinality); len 3..6\n-- Profile for `level`: 0% null; 2 distinct (categorical); len 6..6; top: 4-year(50%), 2-year(50%)\n-- Profile for `control`: 0% null; 3 distinct (categorical); len 6..22; top: Public(33%), Private not-for-profit(33%), Private for-profit(33%)\n-- Profile for `schools_count`: 0% null; 58 distinct (high-cardinality); range 0..1180, avg 24.35\n-- Profile for `counted_pct`: 0% null; 209 distinct (high-cardinality); len 1..4\n-- Profile for `awards_per_state_value`: 0% null; 161 distinct (high-cardinality); len 2..4\n-- Profile for `awards_per_natl_value`: 0% null; 6 distinct (categorical); range 16.5..32.8, avg 23.97; top: 32.8(17%), 25.9(17%), 24.6(17%)\n-- Profile for `exp_award_state_value`: 0% null; 265 distinct (high-cardinality); len 4..6\n-- Profile for `exp_award_natl_value`: 0% null; 6 distinct (categorical); range 24795..101725, avg 50668.17; top: 101725(17%), 66436(17%), 38763(17%)\n-- Profile for `state_appr_value`: 0% null; 50 distinct (high-cardinality); len 4..6\n-- Profile for `state_appr_rank`: 0% null; 50 distinct (high-cardinality); len 1..4\n-- Profile for `grad_rate_rank`: 0% null; 53 distinct (high-cardinality); len 1..4\n-- Profile for `awards_per_rank`: 0% null; 52 distinct (high-cardinality); len 1..4'],
9 ['When did user 39115684 rate the movie "A Way of Life"? A Way of Life\' refers to movie_title; user 39115684 refers to userid = 39115684;\xa0 when the user rate refers to rating_timestamp_utc;', '/* Table: person | p_id: person ID; professor: whether the person is a professor; student: whether the person is a student; hasPosition: has position; inPhase: in phase; yearsInProgram: years in program */\nCREATE TABLE person\n(\n p_id INTEGER -- person ID\n constraint person_pk\n primary key,\n professor INTEGER, -- whether the person is a professor | Values: 0: professor 1: student\n student INTEGER, -- whether the person is a student | Values: 0: professor 1: student\n hasPosition TEXT, -- has position | Values: 0: the person is not a faculty member Common Sense evidence: faculty_aff: affiliated faculty faculty_eme: faculty employee\n inPhase TEXT, -- in phase | Values: 0: the person is not undergoing the phase of qualification\n yearsInProgram TEXT -- years in program | Values: 0: the person is not in any programs Common Sense evidence: yearX means the person is on the Xth year of the program\n)\n-- Approximate rows: 278\n-- Sample values for column `p_id`: 3, 222, 435\n-- Sample values for column `professor`: 0, 1\n-- Sample values for column `student`: 0, 1\n-- Sample values for column `hasPosition`: 0, Faculty, Faculty_adj\n-- Sample values for column `inPhase`: 0, Post_Quals, Post_Generals\n-- Sample values for column `yearsInProgram`: 0, Year_2, Year_5\n-- Table profile: 278 rows\n-- Profile for `p_id`: 0% null; 278 distinct (unique/id); range 3..435, avg 221.06\n-- Profile for `professor`: 0% null; 2 distinct (categorical); range 0..1, avg 0.22; top: 0(78%), 1(22%)\n-- Profile for `student`: 0% null; 2 distinct (categorical); range 0..1, avg 0.78; top: 1(78%), 0(22%)\n-- Profile for `hasPosition`: 0% null; 5 distinct (categorical); len 1..11; top: 0(81%), Faculty(14%), Faculty_adj(2%)\n-- Profile for `inPhase`: 0% null; 4 distinct (categorical); len 1..13; top: 0(50%), Post_Generals(18%), Post_Quals(18%)\n-- Profile for `yearsInProgram`: 0% null; 12 distinct (high-cardinality); len 1..7'],
10 ["In complaints received in 2014, how many of them were submitted via call? in 2014 refers to Date received LIKE '2014%'; submitted via call refers to Submitted via = 'Phone'", '/* Table: client | client_id: client id; district_id → district: district id; social: social number; address_2: address 2; sex: sex of client; day: day of the birthday; month: month of the birthday; year: year when is born; first: first name; middle: middle name; last: last name; phone: phone number; address_1: address 1; state: state code; age: teenager: 13-19 adult: 19-65 elder: > 65; email: google email / account: @gamil.com microsoft email / account: xxx@outl...; city; zipcode */\nCREATE TABLE client\n(\n client_id TEXT -- client id\n primary key,\n sex TEXT, -- sex of client\n day INTEGER, -- day of the birthday\n month INTEGER, -- month of the birthday\n year INTEGER, -- year when is born\n age INTEGER, -- Values: teenager: 13-19 adult: 19-65 elder: > 65\n social TEXT, -- social number | Values: ssn: us id number for each person\n first TEXT, -- first name\n middle TEXT, -- middle name\n last TEXT, -- last name\n phone TEXT, -- phone number\n email TEXT, -- Values: google email / account: @gamil.com microsoft email / account: xxx@outlook.com\n address_1 TEXT, -- address 1\n address_2 TEXT, -- address 2 | Values: entire address = (address_1, address_2)\n city TEXT,\n state TEXT, -- state code\n zipcode INTEGER,\n district_id INTEGER, -- district id\n foreign key (district_id) references district(district_id)\n)\n-- Approximate rows: 5369\n-- Sample values for column `client_id`: C00000001, C00000002, C00000003\n-- Sample values for column `sex`: Female, Male\n-- Sample values for column `day`: 1, 16, 31\n-- Sample values for column `month`: 1, 7, 12\n-- Sample values for column `year`: 1931, 1969, 2007\n-- Sample values for column `age`: 12, 50, 88\n-- Sample values for column `social`: 926-93-2157, 806-94-5725, 614-70-9100\n-- Sample values for column `first`: Emma, Noah, Olivia\n-- Sample values for column `middle`: Avaya, Everest, Brooklynne\n-- Sample values for column `last`: Smith, Thompson, Johnson\n-- Sample values for column `phone`: 367-171-6840, 212-423-7734, 212-425-6932\n-- Sample values for column `email`: emma.smith@gmail.com, noah.thompson@gmail.com, olivia.johnson@outlook.com\n-- Sample values for column `address_1`: 387 Wellington Ave., 75 W. Berkshire St., 36 Second St.\n-- Sample values for column `address_2`: Unit 1, Unit 6, Unit 80\n-- Sample values for column `city`: Albuquerque, New York City, Indianapolis\n-- Sample values for column `state`: NM, NY, IN\n-- Sample values for column `zipcode`: 1101, 44510, 49998\n-- Sample values for column `district_id`: 1, 39, 77\n-- Table profile: 5.4k rows\n-- Profile for `client_id`: 0% null; 5.4k distinct (unique/id); len 9..9\n-- Profile for `sex`: 0% null; 2 distinct (categorical); len 4..6; top: Male(51%), Female(49%)\n-- Profile for `day`: 0% null; 31 distinct (high-cardinality); range 1..31, avg 15.96\n-- Profile for `month`: 0% null; 12 distinct (high-cardinality); range 1..12, avg 6.52\n-- Profile for `year`: 0% null; 77 distinct (high-cardinality); range 1931..2007, avg 1973.2\n-- Profile for `age`: 0% null; 77 distinct (high-cardinality); range 12..88, avg 45.89\n-- Profile for `social`: 0% null; 5.4k distinct (unique/id); len 11..11\n-- Profile for `first`: 0% null; 2.9k distinct (high-cardinality); len 2..11\n-- Profile for `middle`: 0% null; 3.9k distinct (high-cardinality); len 2..12\n-- Profile for `last`: 0% null; 1.8k distinct (high-cardinality); len 2..13\n-- Profile for `phone`: 0% null; 5.4k distinct (unique/id); len 12..12\n-- Profile for `email`: 0% null; 5.4k distinct (unique/id); len 17..38\n-- Profile for `address_1`: 0% null; 5.4k distinct (unique/id); len 9..30\n-- Profile for `address_2`: 98% null; 24 distinct (high-cardinality); len 6..7\n-- Profile for `city`: 0% null; 75 distinct (high-cardinality); len 4..14\n-- Profile for `state`: 0% null; 51 distinct (high-cardinality); len 2..2\n-- Profile for `zipcode`: 0% null; 3.5k distinct (high-cardinality); range 1101..49998, avg 33506.31\n-- Profile for `district_id`: 0% null; 77 distinct (high-cardinality); range 1..77, avg 37.31'],
11 ["Among the active businesses in Arizona, how many businesses work after 12PM? active businesses in Arizona refer to business_id where state = 'Arizona' and active = 'true'; work after 12PM refer to opening_time > '12PM';", '/* Table: position | positionID: position id; educationrequired: education required; positiontitle: position title; minsalary: minimum salary; maxsalary: maximum salary */\nCREATE TABLE position\n(\n positionID INTEGER -- position id\n constraint position_pk\n primary key,\n positiontitle TEXT, -- position title\n educationrequired TEXT, -- education required | Values: Generally, more complex work requires more education year.\n minsalary TEXT, -- minimum salary\n maxsalary TEXT -- maximum salary\n)\n-- Approximate rows: 4\n-- Sample values for column `positionID`: 1, 3, 4\n-- Sample values for column `positiontitle`: Account Representative, Manager, Trainee\n-- Sample values for column `educationrequired`: 4 year degree, 2 year degree, 6 year degree\n-- Sample values for column `minsalary`: US$25,000.00, US$50,000.00, US$18,000.00\n-- Sample values for column `maxsalary`: US$75,000.00, US$150,000.00, US$25,000.00\n-- Table profile: 4 rows\n-- Profile for `positionID`: 0% null; 4 distinct (unique/id); range 1..4, avg 2.5; top: 1(25%), 2(25%), 3(25%)\n-- Profile for `positiontitle`: 0% null; 4 distinct (unique/id); len 7..22; top: Trainee(25%), Regional Manager(25%), Manager(25%)\n-- Profile for `educationrequired`: 0% null; 3 distinct (categorical); len 13..13; top: 4 year degree(50%), 6 year degree(25%), 2 year degree(25%)\n-- Profile for `minsalary`: 0% null; 4 distinct (unique/id); len 12..13; top: US$50,000.00(25%), US$25,000.00(25%), US$18,000.00(25%)\n-- Profile for `maxsalary`: 0% null; 4 distinct (unique/id); len 12..13; top: US$75,000.00(25%), US$250,000.00(25%), US$25,000.00(25%)'],
12]
13scores = model.predict(pairs)
14print(scores.shape)
15# (5,)
16
17# Or rank different texts based on similarity to a single text
18ranks = model.rank(
19 "For the goalie who had the most shutouts in 2010, what's his catching hand? the most shutouts refers to max(SHO); shootCatch = 'L' refers to lefthand; shootCatch = 'R' refers to righthand; shootCatch = 'null' or 'empty' means this player is good at both left and right hand",
20 [
21 '/* Table: TeamsPost | tmID → Teams: team ID; year → Teams; lgID: league ID; G: Games; W: wins; L: loses; T: ties; GF: goals for; GA: goals against; PIM: penalty minutes; BenchMinor: Bench minors (minutes); PPG: Power play goals; PPC: Power play chances; SHA: Shorthanded goals against; PKG: Power play goals against; PKC: Penalty kill chances; SHF: Shorthanded goals for; on */\nCREATE TABLE TeamsPost\n(\n year INTEGER not null,\n lgID TEXT, -- league ID\n tmID TEXT not null, -- team ID\n G INTEGER, -- Games\n W INTEGER, -- wins\n L INTEGER, -- loses\n T INTEGER, -- ties\n GF INTEGER, -- goals for\n GA INTEGER, -- goals against\n PIM TEXT, -- penalty minutes\n BenchMinor TEXT, -- Bench minors (minutes)\n PPG TEXT, -- Power play goals\n PPC TEXT, -- Power play chances\n SHA TEXT, -- Shorthanded goals against\n PKG TEXT, -- Power play goals against\n PKC TEXT, -- Penalty kill chances\n SHF TEXT, -- Shorthanded goals for\n primary key (year, tmID),\n foreign key (year, tmID) references Teams (year, tmID)\n on update cascade on delete cascade\n)\n-- Approximate rows: 927\n-- Sample values for column `year`: 1913, 1962, 2011\n-- Sample values for column `lgID`: NHA, NHL, PCHA\n-- Sample values for column `tmID`: MOC, TBS, MOW\n-- Sample values for column `G`: 2, 14, 26\n-- Sample values for column `W`: 0, 8, 16\n-- Sample values for column `L`: 0, 6, 11\n-- Sample values for column `T`: 0, 2, 4\n-- Sample values for column `GF`: 0, 45, 98\n-- Sample values for column `GA`: 0, 38, 91\n-- Sample values for column `PIM`: 59, 68, 87\n-- Sample values for column `BenchMinor`: 0, 6, 2\n-- Sample values for column `PPG`: 1, 5, 9\n-- Sample values for column `PPC`: 39, 27, 25\n-- Sample values for column `SHA`: 0, 1, 2\n-- Sample values for column `PKG`: 3, 8, 4\n-- Sample values for column `PKC`: 55, 45, 20\n-- Sample values for column `SHF`: 0, 1, 3\n-- Table profile: 927 rows\n-- Profile for `year`: 0% null; 97 distinct (high-cardinality); range 1913..2011, avg 1976.14\n-- Profile for `lgID`: 0% null; 5 distinct (categorical); len 3..4; top: NHL(91%), WHA(6%), PCHA(2%)\n-- Profile for `tmID`: 0% null; 77 distinct (high-cardinality); len 3..3\n-- Profile for `G`: 0% null; 25 distinct (high-cardinality); range 2..26, avg 8.81\n-- Profile for `W`: 0% null; 17 distinct (high-cardinality); range 0..16, avg 4.37\n-- Profile for `L`: 0% null; 12 distinct (high-cardinality); range 0..11, avg 4.37\n-- Profile for `T`: 0% null; 5 distinct (categorical); range 0..4, avg 0.08; top: 0(94%), 1(5%), 2(1%)\n-- Profile for `GF`: 0% null; 91 distinct (high-cardinality); range 0..98, avg 25.6\n-- Profile for `GA`: 0% null; 77 distinct (high-cardinality); range 0..91, avg 25.6\n-- Profile for `PIM`: 9% null; 342 distinct (high-cardinality); len 1..3\n-- Profile for `BenchMinor`: 38% null; 8 distinct (categorical); len 1..2; top: 0(47%), 2(28%), 4(15%)\n-- Profile for `PPG`: 31% null; 31 distinct (high-cardinality); len 1..2\n-- Profile for `PPC`: 37% null; 115 distinct (high-cardinality); len 1..3\n-- Profile for `SHA`: 35% null; 9 distinct (categorical); len 1..1; top: 0(41%), 1(31%), 2(15%)\n-- Profile for `PKG`: 31% null; 27 distinct (high-cardinality); len 1..2\n-- Profile for `PKC`: 37% null; 113 distinct (high-cardinality); len 1..3\n-- Profile for `SHF`: 31% null; 11 distinct (high-cardinality); len 1..2',
22 '/* Table: state_sector_details | level: Level of institution; stateid: state id; control: Public, Private not-for-profit, Private for-profit; state: state name; counted_pct: counted percentage; awards_per_state_value: awards per state value; awards_per_natl_value: awards per national value; exp_award_state_value: expected award state value; exp_award_natl_value: expected award national value; state_appr_value: state appropriation value; references; state_post; schools_count; state_appr_rank; grad_rate_rank; awards_per_rank */\nCREATE TABLE "state_sector_details"\n(\n stateid INTEGER, -- state id\n state TEXT -- state name\n references institution_details (state),\n state_post TEXT,\n level TEXT, -- Level of institution | Values: 4-year: bachelor\'s degree 2-year: associate\'s degree\n control TEXT, -- Values: Public, Private not-for-profit, Private for-profit\n schools_count INTEGER,\n counted_pct TEXT, -- counted percentage\n awards_per_state_value TEXT, -- awards per state value\n awards_per_natl_value REAL, -- awards per national value\n exp_award_state_value TEXT, -- expected award state value\n exp_award_natl_value INTEGER, -- expected award national value\n state_appr_value TEXT, -- state appropriation value\n state_appr_rank TEXT,\n grad_rate_rank TEXT,\n awards_per_rank TEXT,\n primary key (stateid, level, control)\n)\n-- Approximate rows: 312\n-- Sample values for column `stateid`: 0, 29, 56\n-- Sample values for column `state`: United States, Alabama, Alaska\n-- Sample values for column `state_post`: U.S., Ala., Alaska\n-- Sample values for column `level`: 2-year, 4-year\n-- Sample values for column `control`: Private for-profit, Private not-for-profit, Public\n-- Sample values for column `schools_count`: 0, 32, 1180\n-- Sample values for column `counted_pct`: NULL, 61, 62\n-- Sample values for column `awards_per_state_value`: NULL, 18.8, 17.8\n-- Sample values for column `awards_per_natl_value`: 16.5, 24.6, 32.8\n-- Sample values for column `exp_award_state_value`: NULL, 75743, 92268\n-- Sample values for column `exp_award_natl_value`: 24795, 38763, 101725\n-- Sample values for column `state_appr_value`: NULL, 290.68, 496.78\n-- Sample values for column `state_appr_rank`: NULL, 11, 2\n-- Sample values for column `grad_rate_rank`: 23, 18, 8\n-- Sample values for column `awards_per_rank`: NULL, 42, 49\n-- Table profile: 312 rows\n-- Profile for `stateid`: 0% null; 52 distinct (high-cardinality); range 0..56, avg 28.4\n-- Profile for `state`: 0% null; 52 distinct (high-cardinality); len 4..20\n-- Profile for `state_post`: 0% null; 52 distinct (high-cardinality); len 3..6\n-- Profile for `level`: 0% null; 2 distinct (categorical); len 6..6; top: 4-year(50%), 2-year(50%)\n-- Profile for `control`: 0% null; 3 distinct (categorical); len 6..22; top: Public(33%), Private not-for-profit(33%), Private for-profit(33%)\n-- Profile for `schools_count`: 0% null; 58 distinct (high-cardinality); range 0..1180, avg 24.35\n-- Profile for `counted_pct`: 0% null; 209 distinct (high-cardinality); len 1..4\n-- Profile for `awards_per_state_value`: 0% null; 161 distinct (high-cardinality); len 2..4\n-- Profile for `awards_per_natl_value`: 0% null; 6 distinct (categorical); range 16.5..32.8, avg 23.97; top: 32.8(17%), 25.9(17%), 24.6(17%)\n-- Profile for `exp_award_state_value`: 0% null; 265 distinct (high-cardinality); len 4..6\n-- Profile for `exp_award_natl_value`: 0% null; 6 distinct (categorical); range 24795..101725, avg 50668.17; top: 101725(17%), 66436(17%), 38763(17%)\n-- Profile for `state_appr_value`: 0% null; 50 distinct (high-cardinality); len 4..6\n-- Profile for `state_appr_rank`: 0% null; 50 distinct (high-cardinality); len 1..4\n-- Profile for `grad_rate_rank`: 0% null; 53 distinct (high-cardinality); len 1..4\n-- Profile for `awards_per_rank`: 0% null; 52 distinct (high-cardinality); len 1..4',
23 '/* Table: person | p_id: person ID; professor: whether the person is a professor; student: whether the person is a student; hasPosition: has position; inPhase: in phase; yearsInProgram: years in program */\nCREATE TABLE person\n(\n p_id INTEGER -- person ID\n constraint person_pk\n primary key,\n professor INTEGER, -- whether the person is a professor | Values: 0: professor 1: student\n student INTEGER, -- whether the person is a student | Values: 0: professor 1: student\n hasPosition TEXT, -- has position | Values: 0: the person is not a faculty member Common Sense evidence: faculty_aff: affiliated faculty faculty_eme: faculty employee\n inPhase TEXT, -- in phase | Values: 0: the person is not undergoing the phase of qualification\n yearsInProgram TEXT -- years in program | Values: 0: the person is not in any programs Common Sense evidence: yearX means the person is on the Xth year of the program\n)\n-- Approximate rows: 278\n-- Sample values for column `p_id`: 3, 222, 435\n-- Sample values for column `professor`: 0, 1\n-- Sample values for column `student`: 0, 1\n-- Sample values for column `hasPosition`: 0, Faculty, Faculty_adj\n-- Sample values for column `inPhase`: 0, Post_Quals, Post_Generals\n-- Sample values for column `yearsInProgram`: 0, Year_2, Year_5\n-- Table profile: 278 rows\n-- Profile for `p_id`: 0% null; 278 distinct (unique/id); range 3..435, avg 221.06\n-- Profile for `professor`: 0% null; 2 distinct (categorical); range 0..1, avg 0.22; top: 0(78%), 1(22%)\n-- Profile for `student`: 0% null; 2 distinct (categorical); range 0..1, avg 0.78; top: 1(78%), 0(22%)\n-- Profile for `hasPosition`: 0% null; 5 distinct (categorical); len 1..11; top: 0(81%), Faculty(14%), Faculty_adj(2%)\n-- Profile for `inPhase`: 0% null; 4 distinct (categorical); len 1..13; top: 0(50%), Post_Generals(18%), Post_Quals(18%)\n-- Profile for `yearsInProgram`: 0% null; 12 distinct (high-cardinality); len 1..7',
24 '/* Table: client | client_id: client id; district_id → district: district id; social: social number; address_2: address 2; sex: sex of client; day: day of the birthday; month: month of the birthday; year: year when is born; first: first name; middle: middle name; last: last name; phone: phone number; address_1: address 1; state: state code; age: teenager: 13-19 adult: 19-65 elder: > 65; email: google email / account: @gamil.com microsoft email / account: xxx@outl...; city; zipcode */\nCREATE TABLE client\n(\n client_id TEXT -- client id\n primary key,\n sex TEXT, -- sex of client\n day INTEGER, -- day of the birthday\n month INTEGER, -- month of the birthday\n year INTEGER, -- year when is born\n age INTEGER, -- Values: teenager: 13-19 adult: 19-65 elder: > 65\n social TEXT, -- social number | Values: ssn: us id number for each person\n first TEXT, -- first name\n middle TEXT, -- middle name\n last TEXT, -- last name\n phone TEXT, -- phone number\n email TEXT, -- Values: google email / account: @gamil.com microsoft email / account: xxx@outlook.com\n address_1 TEXT, -- address 1\n address_2 TEXT, -- address 2 | Values: entire address = (address_1, address_2)\n city TEXT,\n state TEXT, -- state code\n zipcode INTEGER,\n district_id INTEGER, -- district id\n foreign key (district_id) references district(district_id)\n)\n-- Approximate rows: 5369\n-- Sample values for column `client_id`: C00000001, C00000002, C00000003\n-- Sample values for column `sex`: Female, Male\n-- Sample values for column `day`: 1, 16, 31\n-- Sample values for column `month`: 1, 7, 12\n-- Sample values for column `year`: 1931, 1969, 2007\n-- Sample values for column `age`: 12, 50, 88\n-- Sample values for column `social`: 926-93-2157, 806-94-5725, 614-70-9100\n-- Sample values for column `first`: Emma, Noah, Olivia\n-- Sample values for column `middle`: Avaya, Everest, Brooklynne\n-- Sample values for column `last`: Smith, Thompson, Johnson\n-- Sample values for column `phone`: 367-171-6840, 212-423-7734, 212-425-6932\n-- Sample values for column `email`: emma.smith@gmail.com, noah.thompson@gmail.com, olivia.johnson@outlook.com\n-- Sample values for column `address_1`: 387 Wellington Ave., 75 W. Berkshire St., 36 Second St.\n-- Sample values for column `address_2`: Unit 1, Unit 6, Unit 80\n-- Sample values for column `city`: Albuquerque, New York City, Indianapolis\n-- Sample values for column `state`: NM, NY, IN\n-- Sample values for column `zipcode`: 1101, 44510, 49998\n-- Sample values for column `district_id`: 1, 39, 77\n-- Table profile: 5.4k rows\n-- Profile for `client_id`: 0% null; 5.4k distinct (unique/id); len 9..9\n-- Profile for `sex`: 0% null; 2 distinct (categorical); len 4..6; top: Male(51%), Female(49%)\n-- Profile for `day`: 0% null; 31 distinct (high-cardinality); range 1..31, avg 15.96\n-- Profile for `month`: 0% null; 12 distinct (high-cardinality); range 1..12, avg 6.52\n-- Profile for `year`: 0% null; 77 distinct (high-cardinality); range 1931..2007, avg 1973.2\n-- Profile for `age`: 0% null; 77 distinct (high-cardinality); range 12..88, avg 45.89\n-- Profile for `social`: 0% null; 5.4k distinct (unique/id); len 11..11\n-- Profile for `first`: 0% null; 2.9k distinct (high-cardinality); len 2..11\n-- Profile for `middle`: 0% null; 3.9k distinct (high-cardinality); len 2..12\n-- Profile for `last`: 0% null; 1.8k distinct (high-cardinality); len 2..13\n-- Profile for `phone`: 0% null; 5.4k distinct (unique/id); len 12..12\n-- Profile for `email`: 0% null; 5.4k distinct (unique/id); len 17..38\n-- Profile for `address_1`: 0% null; 5.4k distinct (unique/id); len 9..30\n-- Profile for `address_2`: 98% null; 24 distinct (high-cardinality); len 6..7\n-- Profile for `city`: 0% null; 75 distinct (high-cardinality); len 4..14\n-- Profile for `state`: 0% null; 51 distinct (high-cardinality); len 2..2\n-- Profile for `zipcode`: 0% null; 3.5k distinct (high-cardinality); range 1101..49998, avg 33506.31\n-- Profile for `district_id`: 0% null; 77 distinct (high-cardinality); range 1..77, avg 37.31',
25 '/* Table: position | positionID: position id; educationrequired: education required; positiontitle: position title; minsalary: minimum salary; maxsalary: maximum salary */\nCREATE TABLE position\n(\n positionID INTEGER -- position id\n constraint position_pk\n primary key,\n positiontitle TEXT, -- position title\n educationrequired TEXT, -- education required | Values: Generally, more complex work requires more education year.\n minsalary TEXT, -- minimum salary\n maxsalary TEXT -- maximum salary\n)\n-- Approximate rows: 4\n-- Sample values for column `positionID`: 1, 3, 4\n-- Sample values for column `positiontitle`: Account Representative, Manager, Trainee\n-- Sample values for column `educationrequired`: 4 year degree, 2 year degree, 6 year degree\n-- Sample values for column `minsalary`: US$25,000.00, US$50,000.00, US$18,000.00\n-- Sample values for column `maxsalary`: US$75,000.00, US$150,000.00, US$25,000.00\n-- Table profile: 4 rows\n-- Profile for `positionID`: 0% null; 4 distinct (unique/id); range 1..4, avg 2.5; top: 1(25%), 2(25%), 3(25%)\n-- Profile for `positiontitle`: 0% null; 4 distinct (unique/id); len 7..22; top: Trainee(25%), Regional Manager(25%), Manager(25%)\n-- Profile for `educationrequired`: 0% null; 3 distinct (categorical); len 13..13; top: 4 year degree(50%), 6 year degree(25%), 2 year degree(25%)\n-- Profile for `minsalary`: 0% null; 4 distinct (unique/id); len 12..13; top: US$50,000.00(25%), US$25,000.00(25%), US$18,000.00(25%)\n-- Profile for `maxsalary`: 0% null; 4 distinct (unique/id); len 12..13; top: US$75,000.00(25%), US$250,000.00(25%), US$25,000.00(25%)',
26 ]
27)
28# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]sentence_0, sentence_1, and label| sentence_0 | sentence_1 | label | |
|---|---|---|---|
| type | string | string | int |
| details |
|
|
|
| sentence_0 | sentence_1 | label |
|---|---|---|
For the goalie who had the most shutouts in 2010, what's his catching hand? the most shutouts refers to max(SHO); shootCatch = 'L' refers to lefthand; shootCatch = 'R' refers to righthand; shootCatch = 'null' or 'empty' means this player is good at both left and right hand | /* Table: TeamsPost | tmID → Teams: team ID; year → Teams; lgID: league ID; G: Games; W: wins; L: loses; T: ties; GF: goals for; GA: goals against; PIM: penalty minutes; BenchMinor: Bench minors (minutes); PPG: Power play goals; PPC: Power play chances; SHA: Shorthanded goals against; PKG: Power play goals against; PKC: Penalty kill chances; SHF: Shorthanded goals for; on */ CREATE TABLE TeamsPost ( year INTEGER not null, lgID TEXT, -- league ID tmID TEXT not null, -- team ID G INTEGER, -- Games W INTEGER, -- wins L INTEGER, -- loses T INTEGER, -- ties GF INTEGER, -- goals for GA INTEGER, -- goals against PIM TEXT, -- penalty minutes BenchMinor TEXT, -- Bench minors (minutes) PPG TEXT, -- Power play goals PPC TEXT, -- Power play chances SHA TEXT, -- Shorthanded goals against PKG TEXT, -- Power play goals against ... |
What is the percentage of act number 5 in Titus Andronicus? act number 5 refers to Act = 5; Titus Andronicus refers to Title = 'Titus Andronicus'; percentage = divide(sum(Act = 5), count(Act)) as percentage | /* Table: state_sector_details | level: Level of institution; stateid: state id; control: Public, Private not-for-profit, Private for-profit; state: state name; counted_pct: counted percentage; awards_per_state_value: awards per state value; awards_per_natl_value: awards per national value; exp_award_state_value: expected award state value; exp_award_natl_value: expected award national value; state_appr_value: state appropriation value; references; state_post; schools_count; state_appr_rank; grad_rate_rank; awards_per_rank */ CREATE TABLE "state_sector_details" ( stateid INTEGER, -- state id state TEXT -- state name references institution_details (state), state_post TEXT, level TEXT, -- Level of institution |
When did user 39115684 rate the movie "A Way of Life"? A Way of Life' refers to movie_title; user 39115684 refers to userid = 39115684; when the user rate refers to rating_timestamp_utc; | /* Table: person | p_id: person ID; professor: whether the person is a professor; student: whether the person is a student; hasPosition: has position; inPhase: in phase; yearsInProgram: years in program */ CREATE TABLE person ( p_id INTEGER -- person ID constraint person_pk primary key, professor INTEGER, -- whether the person is a professor |
BinaryCrossEntropyLoss with these parameters:
1{
2 "activation_fn": "torch.nn.modules.linear.Identity",
3 "pos_weight": null
4}per_device_train_batch_size: 32num_train_epochs: 1max_grad_norm: 10.0fp16: Trueper_device_eval_batch_size: 32per_device_train_batch_size: 32num_train_epochs: 1max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: adamw_torchoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 10.0label_smoothing_factor: 0.0bf16: Falsefp16: Truebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: trackioeval_strategy: noper_device_eval_batch_size: 32prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_backend: Noneddp_timeout: 1800fsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}deepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss |
|---|---|---|
| 0.1725 | 500 | 0.1838 |
| 0.3449 | 1000 | 0.1190 |
| 0.5174 | 1500 | 0.0935 |
| 0.6899 | 2000 | 0.0864 |
| 0.8624 | 2500 | 0.0746 |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}