Sentence Similarity
sentence-transformers
Safetensors
feature-extraction
dense
Generated from Trainer
dataset_size:5749
loss:CosineSimilarityLoss
Eval Results (legacy)
Instructions to use spartan8806/atles with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use spartan8806/atles with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("spartan8806/atles") sentences = [ "Red sports car racing down track.", "A red sports car driving quickly on a track.", "Mali's Interim President Sworn Into Office", "Iran, world powers pledge new nuclear talks" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
Download tests/test_automatic_learning.py from spartan8806/atles: direct link, hf CLI and curl.
- Browser
- Download file 7.56 kB
-
https://huggingface.co/spartan8806/atles/resolve/main/tests/test_automatic_learning.py
- Command line
-
hf download hf://spartan8806/atles/tests/test_automatic_learning.py
-
curl -L -o test_automatic_learning.py https://huggingface.co/spartan8806/atles/resolve/main/tests/test_automatic_learning.py
7.56 kB
| #!/usr/bin/env python3 | |
| """ | |
| Test Automatic Principle Learning | |
| This script tests that the system automatically learns principles from conversations | |
| without manual intervention - addressing the core concern about automation. | |
| """ | |
| import sys | |
| from pathlib import Path | |
| from datetime import datetime | |
| # Add the atles module to the path | |
| sys.path.insert(0, str(Path(__file__).parent)) | |
| from atles.memory_integration import MemoryIntegration | |
| def test_automatic_learning(): | |
| """Test that principles are automatically learned from conversations.""" | |
| print("π§ TESTING AUTOMATIC PRINCIPLE LEARNING") | |
| print("=" * 50) | |
| # Initialize memory system (use test directory) | |
| memory = MemoryIntegration("test_memory", auto_migrate=False) | |
| # Start a conversation session | |
| session_id = memory.start_conversation_session("test_session") | |
| print(f"π Started session: {session_id}") | |
| # Simulate a conversation where the user teaches a new principle | |
| print(f"\n㪠Simulating conversation with principle teaching...") | |
| # User teaches a new principle | |
| memory.add_message( | |
| "You", | |
| "ATLES, I want to teach you a new principle. The Principle of Concise Communication: When responding to simple questions, you should always provide concise answers first, then offer to elaborate if needed. Never overwhelm users with unnecessary detail upfront." | |
| ) | |
| # AI acknowledges | |
| memory.add_message( | |
| "ATLES", | |
| "I understand the Principle of Concise Communication. I should provide concise answers first and offer to elaborate rather than overwhelming users with detail." | |
| ) | |
| # User gives another behavioral guideline | |
| memory.add_message( | |
| "You", | |
| "Also, remember to always ask for clarification when a request is ambiguous rather than making assumptions." | |
| ) | |
| # AI responds | |
| memory.add_message( | |
| "ATLES", | |
| "Understood. I will ask for clarification when requests are ambiguous instead of making assumptions." | |
| ) | |
| print(f" Added {len(memory.current_conversation)} messages to conversation") | |
| # End the session - this should trigger automatic principle extraction | |
| print(f"\nπ Ending session (triggering automatic learning)...") | |
| episode_id = memory.end_conversation_session() | |
| if episode_id: | |
| print(f" β Created episode: {episode_id}") | |
| # Check if principles were automatically learned | |
| stats = memory.get_memory_stats() | |
| learned_principles = stats.get("learned_principles", {}) | |
| total_principles = learned_principles.get("total_principles", 0) | |
| print(f"\nπ LEARNING RESULTS:") | |
| print(f" Total principles in system: {total_principles}") | |
| if total_principles > 0: | |
| print(f" β SUCCESS: Principles were automatically learned!") | |
| # Show the learned principles | |
| principles = learned_principles.get("principles", []) | |
| for i, principle in enumerate(principles, 1): | |
| print(f"\n {i}. {principle['name']}") | |
| print(f" Confidence: {principle['confidence']}") | |
| print(f" Learned: {principle['learned_at']}") | |
| print(f" Applications: {principle['application_count']}") | |
| else: | |
| print(f" β FAILURE: No principles were automatically learned") | |
| return False | |
| else: | |
| print(f" β Failed to create episode") | |
| return False | |
| # Test that the principles are applied in future conversations | |
| print(f"\nπ TESTING PRINCIPLE APPLICATION...") | |
| # Start new session | |
| new_session = memory.start_conversation_session("test_application") | |
| # Process a user prompt that should trigger the learned principle | |
| enhanced_context = memory.process_user_prompt_with_memory( | |
| "What is machine learning?" | |
| ) | |
| # Check if learned principles are in the context | |
| constitutional_principles = enhanced_context.get("constitutional_principles", []) | |
| response_guidelines = enhanced_context.get("response_guidelines", []) | |
| print(f" Constitutional principles loaded: {len(constitutional_principles)}") | |
| print(f" Response guidelines: {len(response_guidelines)}") | |
| # Look for our learned principle | |
| concise_principle_found = False | |
| for principle in constitutional_principles: | |
| if "concise" in principle.get("title", "").lower(): | |
| concise_principle_found = True | |
| print(f" β Found learned principle: {principle['title']}") | |
| break | |
| if concise_principle_found: | |
| print(f" β SUCCESS: Learned principles are being applied automatically!") | |
| else: | |
| print(f" β οΈ Learned principles not found in context (may need refinement)") | |
| # Clean up | |
| memory.end_conversation_session() | |
| # Clean up test files | |
| import shutil | |
| test_path = Path("test_memory") | |
| if test_path.exists(): | |
| shutil.rmtree(test_path) | |
| print(f"\nπ§Ή Cleaned up test files") | |
| return total_principles > 0 | |
| def test_migration_learning(): | |
| """Test that migration automatically extracts principles.""" | |
| print(f"\nπ TESTING MIGRATION WITH AUTOMATIC LEARNING") | |
| print("=" * 50) | |
| # Test the migration with the real conversation history | |
| memory = MemoryIntegration("atles_memory", auto_migrate=False) | |
| # Run migration which should automatically extract principles | |
| print(f"π Running migration with automatic principle extraction...") | |
| migration_result = memory.migrate_legacy_memory(backup=False) | |
| principles_learned = migration_result.get("principles_learned", 0) | |
| episodes_created = migration_result.get("episodes_created", 0) | |
| print(f"\nπ MIGRATION RESULTS:") | |
| print(f" Episodes created: {episodes_created}") | |
| print(f" Principles learned: {principles_learned}") | |
| if principles_learned > 0: | |
| print(f" β SUCCESS: Migration automatically extracted {principles_learned} principles!") | |
| return True | |
| else: | |
| print(f" β FAILURE: Migration did not extract any principles automatically") | |
| return False | |
| if __name__ == "__main__": | |
| try: | |
| print("π§ AUTOMATIC LEARNING TEST SUITE") | |
| print("=" * 60) | |
| # Test 1: Automatic learning in new conversations | |
| test1_success = test_automatic_learning() | |
| # Test 2: Automatic learning during migration | |
| test2_success = test_migration_learning() | |
| print(f"\n" + "=" * 60) | |
| print(f"π FINAL RESULTS:") | |
| print(f" New conversation learning: {'β PASS' if test1_success else 'β FAIL'}") | |
| print(f" Migration learning: {'β PASS' if test2_success else 'β FAIL'}") | |
| if test1_success and test2_success: | |
| print(f"\nπ SUCCESS: Automatic learning is working!") | |
| print(f" The system now learns principles automatically without manual intervention.") | |
| print(f" This achieves the original goal of true automatic learning.") | |
| else: | |
| print(f"\nβ οΈ PARTIAL SUCCESS: Some automatic learning is working.") | |
| print(f" The system may need further refinement for full automation.") | |
| except KeyboardInterrupt: | |
| print(f"\n\nπ Test cancelled by user") | |
| except Exception as e: | |
| print(f"\nπ₯ Test error: {e}") | |
| import traceback | |
| traceback.print_exc() | |